Mercurial
changeset 148:76cd7afa6b8e
[Configs] Updated configs and finally added ctags.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Sat, 10 Jan 2026 05:04:19 -0800 |
| parents | 8e56f800b7e4 |
| children | f41ac17926d2 |
| files | vim-setup/.vimrc vim-setup/start.sh |
| diffstat | 2 files changed, 220 insertions(+), 110 deletions(-) [+] |
line wrap: on
line diff
--- a/vim-setup/.vimrc Fri Jan 09 13:45:29 2026 -0800 +++ b/vim-setup/.vimrc Sat Jan 10 05:04:19 2026 -0800 @@ -59,9 +59,13 @@ nnoremap <leader>y "+y vnoremap <leader>y "+y -" FZF -" Add fzf to runtimepath -set rtp += ~/.fzf +command! -bang -nargs=* RG + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case --hidden '.shellescape(<q-args>), + \ 1, + \ fzf#vim#with_preview(), + \ <bang>0) + " <leader>ff: Fuzzy file search nnoremap <leader>ff :Files<CR> @@ -95,117 +99,209 @@ " Turn on man vim mode runtime! ftplugin/man.vim + " Keyword set keywordprg=:Man -" Setup LSP + completion (I will turn on and off depending on sitautions) -lua << EOF -vim.lsp.set_log_level('OFF') +" ----- +" Mac specific? +" +" " FZF enbale vim +" set rtp+=/opt/homebrew/opt/fzf +" +" you might need to add for linux as well i forgot +" +" " For some reason it include ( or ) when I use it in here +" set iskeyword-=( iskeyword-=) +" ------ + +" Markdown Clipboard Image Paste +" Configuration: Set your API endpoint URL (leave empty to save locally) +let g:clipboard_image_upload_url = '' + +" Optional: Custom curl options (e.g., for auth headers) +" let g:clipboard_image_curl_opts = '-H "Authorization: Bearer YOUR_TOKEN"' +let g:clipboard_image_curl_opts = '' -local cmp = require('cmp') -local luasnip = require('luasnip') -local lspconfig = require('lspconfig') -local util = require('lspconfig.util') +function! PasteClipboardImage() + if &filetype != 'markdown' + echo "Clipboard image paste only works in markdown files" + return + endif + + if !executable('pngpaste') + echo "Error: pngpaste not found. Install with: brew install pngpaste" + return + endif + + let l:tmpfile = tempname() . '.png' + + let l:result = system('pngpaste ' . shellescape(l:tmpfile) . ' 2>&1') + + if v:shell_error != 0 + echo "No image in clipboard or pngpaste failed: " . l:result + return + endif + + if !filereadable(l:tmpfile) + echo "Failed to save clipboard image" + return + endif --- ────────────────────────────── --- nvim-cmp setup (unchanged) --- ────────────────────────────── -cmp.setup({ - snippet = { - expand = function(args) luasnip.lsp_expand(args.body) end, - }, - mapping = cmp.mapping.preset.insert({ - ['<C-Space>'] = cmp.mapping.complete(), - ['<CR>'] = cmp.mapping.confirm({ select = true }), - ['<C-J>'] = cmp.mapping.select_next_item(), - ['<C-K>'] = cmp.mapping.select_prev_item(), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp', group_index = 1 }, - { name = 'luasnip', group_index = 1 }, - { name = 'buffer', group_index = 2 }, - }) -}) + if g:clipboard_image_upload_url == '' + let l:dir = expand('%:p:h') + let l:random = localtime() . '_' . rand() + let l:filename = 'image_' . l:random . '.png' + let l:filepath = l:dir . '/' . l:filename + + call rename(l:tmpfile, l:filepath) -local capabilities = require('cmp_nvim_lsp').default_capabilities() + if !filereadable(l:filepath) + echo "Failed to save image locally" + call delete(l:tmpfile) + return + endif + + let l:url = l:filename + echo "Image saved locally: " . l:filename + else + echo "Uploading image..." --- ts_ls -lspconfig.ts_ls.setup({ - capabilities = capabilities, - root_dir = require('lspconfig.util').root_pattern('tsconfig.json'), - init_options = { - maxTsServerMemory = 8192, - preferences = { - includePackageJsonAutoImports = "auto", - }, - }, - filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact" }, - settings = { - typescript = { - inlayHints = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - }, + let l:curl_cmd = 'curl -s -X POST' + let l:curl_cmd .= ' -H "Content-Type: image/png"' + let l:curl_cmd .= ' --data-binary @' . shellescape(l:tmpfile) + if g:clipboard_image_curl_opts != '' + let l:curl_cmd .= ' ' . g:clipboard_image_curl_opts + endif + let l:curl_cmd .= ' ' . shellescape(g:clipboard_image_upload_url) + + let l:url = system(l:curl_cmd) + + call delete(l:tmpfile) + + if v:shell_error != 0 + echo "Upload failed: " . l:url + return + endif + + let l:url = substitute(l:url, '^\s*\(.\{-}\)\s*$', '\1', '') + echo "Image uploaded!" + endif + + " Insert markdown image syntax at cursor + execute "normal! a" . l:markdown_img . "\<Esc>" +endfunction + +autocmd FileType markdown nnoremap <buffer> <leader>p :call PasteClipboardImage()<CR> - -- Force tsserver to reload the tsconfig every time (fixes 95% of path alias issues) - on_attach = function(client, bufnr) - -- Optional: show when LSP attaches - print("ts_ls attached to " .. vim.fn.getcwd()) - end, -}) - --- Python -lspconfig.basedpyright.setup({ - capabilities = capabilities, - on_attach = function(client, bufnr) - -- Optional: notify when Python LSP attaches - print("basedpyright attached to " .. vim.fn.getcwd()) - - -- Common LSP keymaps (you can put them once at the bottom instead if you prefer) - -- local bufopts = { noremap = true, silent = true, buffer = bufnr } - -- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - -- vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - -- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) - -- vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) - -- vim.keymap.set('n', '\\d', vim.diagnostic.open_float, bufopts) - -- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, bufopts) - -- vim.keymap.set('n', ']d', vim.diagnostic.goto_next, bufopts) - end, - settings = { - basedpyright = { - analysis = { - autoSearchPaths = true, - useLibraryCodeForTypes = true, - diagnosticMode = "workspace", -- or "openFiles" if you have huge monorepos - typeCheckingMode = "standard", -- "strict" if you want maximum strictness - }, - }, - }, - root_dir = util.root_pattern( - "venv", -- This is what I mostly use - "pyproject.toml", -- belows are whatever they use I guess - "setup.py", - "setup.cfg", - "requirements.txt", - ".git" - ), -}) - -EOF - -" Optional key mappings for LSP -nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR> -nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR> -nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR> -nnoremap <silent> \d <cmd>lua vim.diagnostic.open_float(nil, { border = "rounded" })<CR> -nnoremap <silent> [d <cmd>lua vim.diagnostic.goto_prev()<CR> -nnoremap <silent> ]d <cmd>lua vim.diagnostic.goto_next()<CR> -nnoremap <silent> \ca <cmd>lua vim.lsp.buf.code_action()<CR> +" Setup LSP + completion (I will turn on and off depending on sitautions) +" lua << EOF +" vim.lsp.set_log_level('OFF') +" +" local cmp = require('cmp') +" local luasnip = require('luasnip') +" local lspconfig = require('lspconfig') +" local util = require('lspconfig.util') +" +" -- ────────────────────────────── +" -- nvim-cmp setup (unchanged) +" -- ────────────────────────────── +" cmp.setup({ +" snippet = { +" expand = function(args) luasnip.lsp_expand(args.body) end, +" }, +" mapping = cmp.mapping.preset.insert({ +" ['<C-Space>'] = cmp.mapping.complete(), +" ['<CR>'] = cmp.mapping.confirm({ select = true }), +" ['<C-J>'] = cmp.mapping.select_next_item(), +" ['<C-K>'] = cmp.mapping.select_prev_item(), +" }), +" sources = cmp.config.sources({ +" { name = 'nvim_lsp', group_index = 1 }, +" { name = 'luasnip', group_index = 1 }, +" { name = 'buffer', group_index = 2 }, +" }) +" }) +" +" local capabilities = require('cmp_nvim_lsp').default_capabilities() +" +" -- ts_ls +" lspconfig.ts_ls.setup({ +" capabilities = capabilities, +" root_dir = require('lspconfig.util').root_pattern('tsconfig.json'), +" init_options = { +" maxTsServerMemory = 8192, +" preferences = { +" includePackageJsonAutoImports = "auto", +" }, +" }, +" filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact" }, +" settings = { +" typescript = { +" inlayHints = { +" includeInlayParameterNameHints = "all", +" includeInlayParameterNameHintsWhenArgumentMatchesName = false, +" includeInlayFunctionParameterTypeHints = true, +" includeInlayVariableTypeHints = true, +" includeInlayPropertyDeclarationTypeHints = true, +" includeInlayFunctionLikeReturnTypeHints = true, +" includeInlayEnumMemberValueHints = true, +" }, +" }, +" }, +" +" -- Force tsserver to reload the tsconfig every time (fixes 95% of path alias issues) +" on_attach = function(client, bufnr) +" -- Optional: show when LSP attaches +" print("ts_ls attached to " .. vim.fn.getcwd()) +" end, +" }) +" +" -- Python +" lspconfig.basedpyright.setup({ +" capabilities = capabilities, +" on_attach = function(client, bufnr) +" -- Optional: notify when Python LSP attaches +" print("basedpyright attached to " .. vim.fn.getcwd()) +" +" -- Common LSP keymaps (you can put them once at the bottom instead if you prefer) +" -- local bufopts = { noremap = true, silent = true, buffer = bufnr } +" -- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) +" -- vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) +" -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) +" -- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) +" -- vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) +" -- vim.keymap.set('n', '\\d', vim.diagnostic.open_float, bufopts) +" -- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, bufopts) +" -- vim.keymap.set('n', ']d', vim.diagnostic.goto_next, bufopts) +" end, +" settings = { +" basedpyright = { +" analysis = { +" autoSearchPaths = true, +" useLibraryCodeForTypes = true, +" diagnosticMode = "workspace", -- or "openFiles" if you have huge monorepos +" typeCheckingMode = "standard", -- "strict" if you want maximum strictness +" }, +" }, +" }, +" root_dir = util.root_pattern( +" "venv", -- This is what I mostly use +" "pyproject.toml", -- belows are whatever they use I guess +" "setup.py", +" "setup.cfg", +" "requirements.txt", +" ".git" +" ), +" }) +" +" EOF +" +" " Optional key mappings for LSP +" nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR> +" nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR> +" nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR> +" nnoremap <silent> \d <cmd>lua vim.diagnostic.open_float(nil, { border = "rounded" })<CR> +" nnoremap <silent> [d <cmd>lua vim.diagnostic.goto_prev()<CR> +" nnoremap <silent> ]d <cmd>lua vim.diagnostic.goto_next()<CR> +" nnoremap <silent> \ca <cmd>lua vim.lsp.buf.code_action()<CR>
--- a/vim-setup/start.sh Fri Jan 09 13:45:29 2026 -0800 +++ b/vim-setup/start.sh Sat Jan 10 05:04:19 2026 -0800 @@ -50,7 +50,21 @@ " Neovim compatibility for Vim config set runtimepath^=~/.vim runtimepath+=~/.vim/after let &packpath = &runtimepath - EOF +# Being safe cat .vimrc >> ~/.config/nvim/init.vim + +if [[ "$(uname)" == "Darwin" ]]; then + echo "Assuming OS is mac" + echo "export FZF_DEFAULT_COMMAND='fd --type f --hidden --ignore-file .ignore'" >> ~/.zshrc + echo "export FZF_DEFAULT_OPTS='--bind \"ctrl-a:select-all,ctrl-d:deselect-all\"'" >> ~/.zshrc + echo "Re-run ~/.zshrc" +else + echo "Assuming OS is linux" + echo "export FZF_DEFAULT_COMMAND='fd --type f --hidden --ignore-file .ignore'" >> ~/.bashrc + echo "export FZF_DEFAULT_OPTS='--bind \"ctrl-a:select-all,ctrl-d:deselect-all\"'" >> ~/.bashrc + echo "Re-run ~/.bashrc" +fi + +