Mercurial
comparison vim-setup/.vimrc @ 43:5e6a5d3c6868
[Personal] Moving my vim-set up config here.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 01 Dec 2025 22:43:40 -0800 |
| parents | |
| children | 983769fba767 |
comparison
equal
deleted
inserted
replaced
| 42:c2706ffb442b | 43:5e6a5d3c6868 |
|---|---|
| 1 " Line numbers | |
| 2 set number | |
| 3 set relativenumber | |
| 4 | |
| 5 " Turn off error | |
| 6 set noerrorbells | |
| 7 set novisualbell | |
| 8 set t_vb= | |
| 9 | |
| 10 " Indentation | |
| 11 set tabstop=2 | |
| 12 set shiftwidth=2 | |
| 13 set expandtab | |
| 14 set autoindent | |
| 15 | |
| 16 " Syntax | |
| 17 syntax on | |
| 18 filetype plugin indent on | |
| 19 set termguicolors | |
| 20 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" | |
| 21 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" | |
| 22 colorscheme nightfly | |
| 23 " Force turn on unless it is over 1M LOC | |
| 24 autocmd BufReadPre * if getfsize(expand("%")) > 1000000 | syntax off | endif | |
| 25 | |
| 26 " Line wrapping | |
| 27 set nowrap | |
| 28 | |
| 29 " Search settings | |
| 30 set ignorecase | |
| 31 set smartcase | |
| 32 set hlsearch | |
| 33 set incsearch | |
| 34 | |
| 35 " Cursor line | |
| 36 set cursorline | |
| 37 | |
| 38 " Appearance | |
| 39 set termguicolors | |
| 40 set background=dark | |
| 41 set signcolumn=yes | |
| 42 | |
| 43 " Backspace behavior | |
| 44 set backspace=indent,eol,start | |
| 45 | |
| 46 " Clipboard | |
| 47 set clipboard+=unnamedplus | |
| 48 | |
| 49 " Split window behavior | |
| 50 set splitright | |
| 51 set splitbelow | |
| 52 set splitbelow | |
| 53 | |
| 54 " General Keymaps | |
| 55 " Map semicolon to colon in normal mode | |
| 56 nnoremap ; : | |
| 57 | |
| 58 " Yank into clipboard | |
| 59 nnoremap <leader>y "+y | |
| 60 vnoremap <leader>y "+y | |
| 61 | |
| 62 " <leader>ff: Fuzzy file search | |
| 63 nnoremap <leader>ff :Files<CR> | |
| 64 | |
| 65 " <leader>fb: Fuzzy search within buffer | |
| 66 nnoremap <leader>fb :Buffers<CR> | |
| 67 | |
| 68 " <leader>ft: ctag search | |
| 69 nnoremap <leader>ft :Tags<CR> | |
| 70 | |
| 71 " <leader>fs: Ripgrep search for word (normal mode) | |
| 72 nnoremap <leader>fs :RG<CR> | |
| 73 | |
| 74 " <leader>fs: Ripgrep search for selected text (visual mode) | |
| 75 vnoremap <leader>fs :<C-u>execute 'Rg ' . getreg('"')<CR> | |
| 76 | |
| 77 " Open man in vim | |
| 78 noremap <c-k> :h <cword><cr> | |
| 79 | |
| 80 " vim wiki | |
| 81 " Set the directory where your wiki pages will be stored | |
| 82 let g:wiki_root = expand('~/wiki/') | |
| 83 | |
| 84 " Set wiki syntax and file extensions | |
| 85 let g:wiki_filetypes = ['md', 'wiki'] | |
| 86 | |
| 87 " Enable global mappings (optional) | |
| 88 let g:wiki_global_mappings = 1 | |
| 89 | |
| 90 " Enable links to markdown files | |
| 91 let g:wiki_link_extension = '.md' | |
| 92 | |
| 93 " Turn on man vim mode | |
| 94 runtime! ftplugin/man.vim | |
| 95 " Keyword | |
| 96 set keywordprg=:Man | |
| 97 | |
| 98 " Setup LSP + completion (I will turn on and off depending on sitautions) | |
| 99 lua << EOF | |
| 100 vim.lsp.set_log_level('OFF') | |
| 101 | |
| 102 local cmp = require('cmp') | |
| 103 local luasnip = require('luasnip') | |
| 104 local lspconfig = require('lspconfig') | |
| 105 local util = require('lspconfig.util') | |
| 106 | |
| 107 -- ────────────────────────────── | |
| 108 -- nvim-cmp setup (unchanged) | |
| 109 -- ────────────────────────────── | |
| 110 cmp.setup({ | |
| 111 snippet = { | |
| 112 expand = function(args) luasnip.lsp_expand(args.body) end, | |
| 113 }, | |
| 114 mapping = cmp.mapping.preset.insert({ | |
| 115 ['<C-Space>'] = cmp.mapping.complete(), | |
| 116 ['<CR>'] = cmp.mapping.confirm({ select = true }), | |
| 117 ['<C-J>'] = cmp.mapping.select_next_item(), | |
| 118 ['<C-K>'] = cmp.mapping.select_prev_item(), | |
| 119 }), | |
| 120 sources = cmp.config.sources({ | |
| 121 { name = 'nvim_lsp', group_index = 1 }, | |
| 122 { name = 'luasnip', group_index = 1 }, | |
| 123 { name = 'buffer', group_index = 2 }, | |
| 124 }) | |
| 125 }) | |
| 126 | |
| 127 local capabilities = require('cmp_nvim_lsp').default_capabilities() | |
| 128 | |
| 129 -- ts_ls | |
| 130 lspconfig.ts_ls.setup({ | |
| 131 capabilities = capabilities, | |
| 132 root_dir = require('lspconfig.util').root_pattern('tsconfig.json'), | |
| 133 init_options = { | |
| 134 maxTsServerMemory = 8192, | |
| 135 preferences = { | |
| 136 includePackageJsonAutoImports = "auto", | |
| 137 }, | |
| 138 }, | |
| 139 filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact" }, | |
| 140 settings = { | |
| 141 typescript = { | |
| 142 inlayHints = { | |
| 143 includeInlayParameterNameHints = "all", | |
| 144 includeInlayParameterNameHintsWhenArgumentMatchesName = false, | |
| 145 includeInlayFunctionParameterTypeHints = true, | |
| 146 includeInlayVariableTypeHints = true, | |
| 147 includeInlayPropertyDeclarationTypeHints = true, | |
| 148 includeInlayFunctionLikeReturnTypeHints = true, | |
| 149 includeInlayEnumMemberValueHints = true, | |
| 150 }, | |
| 151 }, | |
| 152 }, | |
| 153 | |
| 154 -- Force tsserver to reload the tsconfig every time (fixes 95% of path alias issues) | |
| 155 on_attach = function(client, bufnr) | |
| 156 -- Optional: show when LSP attaches | |
| 157 print("ts_ls attached to " .. vim.fn.getcwd()) | |
| 158 end, | |
| 159 }) | |
| 160 | |
| 161 -- Python | |
| 162 lspconfig.basedpyright.setup({ | |
| 163 capabilities = capabilities, | |
| 164 on_attach = function(client, bufnr) | |
| 165 -- Optional: notify when Python LSP attaches | |
| 166 print("basedpyright attached to " .. vim.fn.getcwd()) | |
| 167 | |
| 168 -- Common LSP keymaps (you can put them once at the bottom instead if you prefer) | |
| 169 -- local bufopts = { noremap = true, silent = true, buffer = bufnr } | |
| 170 -- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) | |
| 171 -- vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) | |
| 172 -- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) | |
| 173 -- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts) | |
| 174 -- vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts) | |
| 175 -- vim.keymap.set('n', '\\d', vim.diagnostic.open_float, bufopts) | |
| 176 -- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, bufopts) | |
| 177 -- vim.keymap.set('n', ']d', vim.diagnostic.goto_next, bufopts) | |
| 178 end, | |
| 179 settings = { | |
| 180 basedpyright = { | |
| 181 analysis = { | |
| 182 autoSearchPaths = true, | |
| 183 useLibraryCodeForTypes = true, | |
| 184 diagnosticMode = "workspace", -- or "openFiles" if you have huge monorepos | |
| 185 typeCheckingMode = "standard", -- "strict" if you want maximum strictness | |
| 186 }, | |
| 187 }, | |
| 188 }, | |
| 189 root_dir = util.root_pattern( | |
| 190 "venv", -- This is what I mostly use | |
| 191 "pyproject.toml", -- belows are whatever they use I guess | |
| 192 "setup.py", | |
| 193 "setup.cfg", | |
| 194 "requirements.txt", | |
| 195 ".git" | |
| 196 ), | |
| 197 }) | |
| 198 | |
| 199 EOF | |
| 200 | |
| 201 " Optional key mappings for LSP | |
| 202 nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR> | |
| 203 nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR> | |
| 204 nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR> | |
| 205 nnoremap <silent> \d <cmd>lua vim.diagnostic.open_float(nil, { border = "rounded" })<CR> | |
| 206 nnoremap <silent> [d <cmd>lua vim.diagnostic.goto_prev()<CR> | |
| 207 nnoremap <silent> ]d <cmd>lua vim.diagnostic.goto_next()<CR> | |
| 208 nnoremap <silent> \ca <cmd>lua vim.lsp.buf.code_action()<CR> |