Mercurial
comparison vim-setup/.vimrc @ 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 | 983769fba767 |
| children | c37490913530 |
comparison
equal
deleted
inserted
replaced
| 146:8e56f800b7e4 | 148:76cd7afa6b8e |
|---|---|
| 57 | 57 |
| 58 " Yank into clipboard | 58 " Yank into clipboard |
| 59 nnoremap <leader>y "+y | 59 nnoremap <leader>y "+y |
| 60 vnoremap <leader>y "+y | 60 vnoremap <leader>y "+y |
| 61 | 61 |
| 62 " FZF | 62 command! -bang -nargs=* RG |
| 63 " Add fzf to runtimepath | 63 \ call fzf#vim#grep( |
| 64 set rtp += ~/.fzf | 64 \ 'rg --column --line-number --no-heading --color=always --smart-case --hidden '.shellescape(<q-args>), |
| 65 \ 1, | |
| 66 \ fzf#vim#with_preview(), | |
| 67 \ <bang>0) | |
| 68 | |
| 65 " <leader>ff: Fuzzy file search | 69 " <leader>ff: Fuzzy file search |
| 66 nnoremap <leader>ff :Files<CR> | 70 nnoremap <leader>ff :Files<CR> |
| 67 | 71 |
| 68 " <leader>fb: Fuzzy search within buffer | 72 " <leader>fb: Fuzzy search within buffer |
| 69 nnoremap <leader>fb :Buffers<CR> | 73 nnoremap <leader>fb :Buffers<CR> |
| 93 " Enable links to markdown files | 97 " Enable links to markdown files |
| 94 let g:wiki_link_extension = '.md' | 98 let g:wiki_link_extension = '.md' |
| 95 | 99 |
| 96 " Turn on man vim mode | 100 " Turn on man vim mode |
| 97 runtime! ftplugin/man.vim | 101 runtime! ftplugin/man.vim |
| 102 | |
| 98 " Keyword | 103 " Keyword |
| 99 set keywordprg=:Man | 104 set keywordprg=:Man |
| 100 | 105 |
| 106 " ----- | |
| 107 " Mac specific? | |
| 108 " | |
| 109 " " FZF enbale vim | |
| 110 " set rtp+=/opt/homebrew/opt/fzf | |
| 111 " | |
| 112 " you might need to add for linux as well i forgot | |
| 113 " | |
| 114 " " For some reason it include ( or ) when I use it in here | |
| 115 " set iskeyword-=( iskeyword-=) | |
| 116 " ------ | |
| 117 | |
| 118 " Markdown Clipboard Image Paste | |
| 119 " Configuration: Set your API endpoint URL (leave empty to save locally) | |
| 120 let g:clipboard_image_upload_url = '' | |
| 121 | |
| 122 " Optional: Custom curl options (e.g., for auth headers) | |
| 123 " let g:clipboard_image_curl_opts = '-H "Authorization: Bearer YOUR_TOKEN"' | |
| 124 let g:clipboard_image_curl_opts = '' | |
| 125 | |
| 126 function! PasteClipboardImage() | |
| 127 if &filetype != 'markdown' | |
| 128 echo "Clipboard image paste only works in markdown files" | |
| 129 return | |
| 130 endif | |
| 131 | |
| 132 if !executable('pngpaste') | |
| 133 echo "Error: pngpaste not found. Install with: brew install pngpaste" | |
| 134 return | |
| 135 endif | |
| 136 | |
| 137 let l:tmpfile = tempname() . '.png' | |
| 138 | |
| 139 let l:result = system('pngpaste ' . shellescape(l:tmpfile) . ' 2>&1') | |
| 140 | |
| 141 if v:shell_error != 0 | |
| 142 echo "No image in clipboard or pngpaste failed: " . l:result | |
| 143 return | |
| 144 endif | |
| 145 | |
| 146 if !filereadable(l:tmpfile) | |
| 147 echo "Failed to save clipboard image" | |
| 148 return | |
| 149 endif | |
| 150 | |
| 151 if g:clipboard_image_upload_url == '' | |
| 152 let l:dir = expand('%:p:h') | |
| 153 let l:random = localtime() . '_' . rand() | |
| 154 let l:filename = 'image_' . l:random . '.png' | |
| 155 let l:filepath = l:dir . '/' . l:filename | |
| 156 | |
| 157 call rename(l:tmpfile, l:filepath) | |
| 158 | |
| 159 if !filereadable(l:filepath) | |
| 160 echo "Failed to save image locally" | |
| 161 call delete(l:tmpfile) | |
| 162 return | |
| 163 endif | |
| 164 | |
| 165 let l:url = l:filename | |
| 166 echo "Image saved locally: " . l:filename | |
| 167 else | |
| 168 echo "Uploading image..." | |
| 169 | |
| 170 let l:curl_cmd = 'curl -s -X POST' | |
| 171 let l:curl_cmd .= ' -H "Content-Type: image/png"' | |
| 172 let l:curl_cmd .= ' --data-binary @' . shellescape(l:tmpfile) | |
| 173 if g:clipboard_image_curl_opts != '' | |
| 174 let l:curl_cmd .= ' ' . g:clipboard_image_curl_opts | |
| 175 endif | |
| 176 let l:curl_cmd .= ' ' . shellescape(g:clipboard_image_upload_url) | |
| 177 | |
| 178 let l:url = system(l:curl_cmd) | |
| 179 | |
| 180 call delete(l:tmpfile) | |
| 181 | |
| 182 if v:shell_error != 0 | |
| 183 echo "Upload failed: " . l:url | |
| 184 return | |
| 185 endif | |
| 186 | |
| 187 let l:url = substitute(l:url, '^\s*\(.\{-}\)\s*$', '\1', '') | |
| 188 echo "Image uploaded!" | |
| 189 endif | |
| 190 | |
| 191 " Insert markdown image syntax at cursor | |
| 192 execute "normal! a" . l:markdown_img . "\<Esc>" | |
| 193 endfunction | |
| 194 | |
| 195 autocmd FileType markdown nnoremap <buffer> <leader>p :call PasteClipboardImage()<CR> | |
| 196 | |
| 101 " Setup LSP + completion (I will turn on and off depending on sitautions) | 197 " Setup LSP + completion (I will turn on and off depending on sitautions) |
| 102 lua << EOF | 198 " lua << EOF |
| 103 vim.lsp.set_log_level('OFF') | 199 " vim.lsp.set_log_level('OFF') |
| 104 | 200 " |
| 105 local cmp = require('cmp') | 201 " local cmp = require('cmp') |
| 106 local luasnip = require('luasnip') | 202 " local luasnip = require('luasnip') |
| 107 local lspconfig = require('lspconfig') | 203 " local lspconfig = require('lspconfig') |
| 108 local util = require('lspconfig.util') | 204 " local util = require('lspconfig.util') |
| 109 | 205 " |
| 110 -- ────────────────────────────── | 206 " -- ────────────────────────────── |
| 111 -- nvim-cmp setup (unchanged) | 207 " -- nvim-cmp setup (unchanged) |
| 112 -- ────────────────────────────── | 208 " -- ────────────────────────────── |
| 113 cmp.setup({ | 209 " cmp.setup({ |
| 114 snippet = { | 210 " snippet = { |
| 115 expand = function(args) luasnip.lsp_expand(args.body) end, | 211 " expand = function(args) luasnip.lsp_expand(args.body) end, |
| 116 }, | 212 " }, |
| 117 mapping = cmp.mapping.preset.insert({ | 213 " mapping = cmp.mapping.preset.insert({ |
| 118 ['<C-Space>'] = cmp.mapping.complete(), | 214 " ['<C-Space>'] = cmp.mapping.complete(), |
| 119 ['<CR>'] = cmp.mapping.confirm({ select = true }), | 215 " ['<CR>'] = cmp.mapping.confirm({ select = true }), |
| 120 ['<C-J>'] = cmp.mapping.select_next_item(), | 216 " ['<C-J>'] = cmp.mapping.select_next_item(), |
| 121 ['<C-K>'] = cmp.mapping.select_prev_item(), | 217 " ['<C-K>'] = cmp.mapping.select_prev_item(), |
| 122 }), | 218 " }), |
| 123 sources = cmp.config.sources({ | 219 " sources = cmp.config.sources({ |
| 124 { name = 'nvim_lsp', group_index = 1 }, | 220 " { name = 'nvim_lsp', group_index = 1 }, |
| 125 { name = 'luasnip', group_index = 1 }, | 221 " { name = 'luasnip', group_index = 1 }, |
| 126 { name = 'buffer', group_index = 2 }, | 222 " { name = 'buffer', group_index = 2 }, |
| 127 }) | 223 " }) |
| 128 }) | 224 " }) |
| 129 | 225 " |
| 130 local capabilities = require('cmp_nvim_lsp').default_capabilities() | 226 " local capabilities = require('cmp_nvim_lsp').default_capabilities() |
| 131 | 227 " |
| 132 -- ts_ls | 228 " -- ts_ls |
| 133 lspconfig.ts_ls.setup({ | 229 " lspconfig.ts_ls.setup({ |
| 134 capabilities = capabilities, | 230 " capabilities = capabilities, |
| 135 root_dir = require('lspconfig.util').root_pattern('tsconfig.json'), | 231 " root_dir = require('lspconfig.util').root_pattern('tsconfig.json'), |
| 136 init_options = { | 232 " init_options = { |
| 137 maxTsServerMemory = 8192, | 233 " maxTsServerMemory = 8192, |
| 138 preferences = { | 234 " preferences = { |
| 139 includePackageJsonAutoImports = "auto", | 235 " includePackageJsonAutoImports = "auto", |
| 140 }, | 236 " }, |
| 141 }, | 237 " }, |
| 142 filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact" }, | 238 " filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact" }, |
| 143 settings = { | 239 " settings = { |
| 144 typescript = { | 240 " typescript = { |
| 145 inlayHints = { | 241 " inlayHints = { |
| 146 includeInlayParameterNameHints = "all", | 242 " includeInlayParameterNameHints = "all", |
| 147 includeInlayParameterNameHintsWhenArgumentMatchesName = false, | 243 " includeInlayParameterNameHintsWhenArgumentMatchesName = false, |
| 148 includeInlayFunctionParameterTypeHints = true, | 244 " includeInlayFunctionParameterTypeHints = true, |
| 149 includeInlayVariableTypeHints = true, | 245 " includeInlayVariableTypeHints = true, |
| 150 includeInlayPropertyDeclarationTypeHints = true, | 246 " includeInlayPropertyDeclarationTypeHints = true, |
| 151 includeInlayFunctionLikeReturnTypeHints = true, | 247 " includeInlayFunctionLikeReturnTypeHints = true, |
| 152 includeInlayEnumMemberValueHints = true, | 248 " includeInlayEnumMemberValueHints = true, |
| 153 }, | 249 " }, |
| 154 }, | 250 " }, |
| 155 }, | 251 " }, |
| 156 | 252 " |
| 157 -- Force tsserver to reload the tsconfig every time (fixes 95% of path alias issues) | 253 " -- Force tsserver to reload the tsconfig every time (fixes 95% of path alias issues) |
| 158 on_attach = function(client, bufnr) | 254 " on_attach = function(client, bufnr) |
| 159 -- Optional: show when LSP attaches | 255 " -- Optional: show when LSP attaches |
| 160 print("ts_ls attached to " .. vim.fn.getcwd()) | 256 " print("ts_ls attached to " .. vim.fn.getcwd()) |
| 161 end, | 257 " end, |
| 162 }) | 258 " }) |
| 163 | 259 " |
| 164 -- Python | 260 " -- Python |
| 165 lspconfig.basedpyright.setup({ | 261 " lspconfig.basedpyright.setup({ |
| 166 capabilities = capabilities, | 262 " capabilities = capabilities, |
| 167 on_attach = function(client, bufnr) | 263 " on_attach = function(client, bufnr) |
| 168 -- Optional: notify when Python LSP attaches | 264 " -- Optional: notify when Python LSP attaches |
| 169 print("basedpyright attached to " .. vim.fn.getcwd()) | 265 " print("basedpyright attached to " .. vim.fn.getcwd()) |
| 170 | 266 " |
| 171 -- Common LSP keymaps (you can put them once at the bottom instead if you prefer) | 267 " -- Common LSP keymaps (you can put them once at the bottom instead if you prefer) |
| 172 -- local bufopts = { noremap = true, silent = true, buffer = bufnr } | 268 " -- local bufopts = { noremap = true, silent = true, buffer = bufnr } |
| 173 -- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) | 269 " -- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) |
| 174 -- vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) | 270 " -- vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) |
| 175 -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) | 271 " -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) |
| 176 -- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) | 272 " -- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) |
| 177 -- vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) | 273 " -- vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) |
| 178 -- vim.keymap.set('n', '\\d', vim.diagnostic.open_float, bufopts) | 274 " -- vim.keymap.set('n', '\\d', vim.diagnostic.open_float, bufopts) |
| 179 -- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, bufopts) | 275 " -- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, bufopts) |
| 180 -- vim.keymap.set('n', ']d', vim.diagnostic.goto_next, bufopts) | 276 " -- vim.keymap.set('n', ']d', vim.diagnostic.goto_next, bufopts) |
| 181 end, | 277 " end, |
| 182 settings = { | 278 " settings = { |
| 183 basedpyright = { | 279 " basedpyright = { |
| 184 analysis = { | 280 " analysis = { |
| 185 autoSearchPaths = true, | 281 " autoSearchPaths = true, |
| 186 useLibraryCodeForTypes = true, | 282 " useLibraryCodeForTypes = true, |
| 187 diagnosticMode = "workspace", -- or "openFiles" if you have huge monorepos | 283 " diagnosticMode = "workspace", -- or "openFiles" if you have huge monorepos |
| 188 typeCheckingMode = "standard", -- "strict" if you want maximum strictness | 284 " typeCheckingMode = "standard", -- "strict" if you want maximum strictness |
| 189 }, | 285 " }, |
| 190 }, | 286 " }, |
| 191 }, | 287 " }, |
| 192 root_dir = util.root_pattern( | 288 " root_dir = util.root_pattern( |
| 193 "venv", -- This is what I mostly use | 289 " "venv", -- This is what I mostly use |
| 194 "pyproject.toml", -- belows are whatever they use I guess | 290 " "pyproject.toml", -- belows are whatever they use I guess |
| 195 "setup.py", | 291 " "setup.py", |
| 196 "setup.cfg", | 292 " "setup.cfg", |
| 197 "requirements.txt", | 293 " "requirements.txt", |
| 198 ".git" | 294 " ".git" |
| 199 ), | 295 " ), |
| 200 }) | 296 " }) |
| 201 | 297 " |
| 202 EOF | 298 " EOF |
| 203 | 299 " |
| 204 " Optional key mappings for LSP | 300 " " Optional key mappings for LSP |
| 205 nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR> | 301 " nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR> |
| 206 nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR> | 302 " nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR> |
| 207 nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR> | 303 " nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR> |
| 208 nnoremap <silent> \d <cmd>lua vim.diagnostic.open_float(nil, { border = "rounded" })<CR> | 304 " nnoremap <silent> \d <cmd>lua vim.diagnostic.open_float(nil, { border = "rounded" })<CR> |
| 209 nnoremap <silent> [d <cmd>lua vim.diagnostic.goto_prev()<CR> | 305 " nnoremap <silent> [d <cmd>lua vim.diagnostic.goto_prev()<CR> |
| 210 nnoremap <silent> ]d <cmd>lua vim.diagnostic.goto_next()<CR> | 306 " nnoremap <silent> ]d <cmd>lua vim.diagnostic.goto_next()<CR> |
| 211 nnoremap <silent> \ca <cmd>lua vim.lsp.buf.code_action()<CR> | 307 " nnoremap <silent> \ca <cmd>lua vim.lsp.buf.code_action()<CR> |