diff options
Diffstat (limited to 'vim/.vim')
| -rw-r--r-- | vim/.vim/ftplugin/python.vim | 8 | ||||
| -rwxr-xr-x | vim/.vim/vimrc | 80 |
2 files changed, 66 insertions, 22 deletions
diff --git a/vim/.vim/ftplugin/python.vim b/vim/.vim/ftplugin/python.vim index 183ef4b..e847d12 100644 --- a/vim/.vim/ftplugin/python.vim +++ b/vim/.vim/ftplugin/python.vim | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | set tabstop=8 | 1 | setlocal tabstop=8 |
| 2 | set expandtab | 2 | setlocal expandtab |
| 3 | set shiftwidth=4 | 3 | setlocal shiftwidth=4 |
| 4 | set softtabstop=4 | 4 | setlocal softtabstop=4 |
diff --git a/vim/.vim/vimrc b/vim/.vim/vimrc index 5fd4e01..aa97947 100755 --- a/vim/.vim/vimrc +++ b/vim/.vim/vimrc | |||
| @@ -6,9 +6,9 @@ Plug 'edkolev/tmuxline.vim' | |||
| 6 | " Plug 'ervandew/supertab' | 6 | " Plug 'ervandew/supertab' |
| 7 | Plug 'mhinz/vim-janah' | 7 | Plug 'mhinz/vim-janah' |
| 8 | Plug 'mhinz/vim-signify' | 8 | Plug 'mhinz/vim-signify' |
| 9 | Plug 'scrooloose/nerdcommenter' | 9 | Plug 'preservim/nerdcommenter' |
| 10 | Plug 'scrooloose/nerdtree' | 10 | Plug 'preservim/nerdtree' |
| 11 | Plug 'scrooloose/syntastic' | 11 | Plug 'dense-analysis/ale' |
| 12 | Plug 'tpope/vim-fugitive' | 12 | Plug 'tpope/vim-fugitive' |
| 13 | Plug 'unblevable/quick-scope' | 13 | Plug 'unblevable/quick-scope' |
| 14 | Plug 'vim-airline/vim-airline-themes' | 14 | Plug 'vim-airline/vim-airline-themes' |
| @@ -23,24 +23,26 @@ endif | |||
| 23 | 23 | ||
| 24 | if executable('python') || executable('python3') | 24 | if executable('python') || executable('python3') |
| 25 | Plug 'davidhalter/jedi-vim' | 25 | Plug 'davidhalter/jedi-vim' |
| 26 | " YCM handles completion (async); keep jedi-vim for goto/rename only | ||
| 27 | let g:jedi#completions_enabled = 0 | ||
| 26 | endif | 28 | endif |
| 27 | 29 | ||
| 28 | if has('python') || has('python3') | 30 | if has('python') || has('python3') |
| 29 | let g:ycm_install_command = './install.py --clang-completer' | 31 | let g:ycm_install_command = './install.py --clang-completer' |
| 30 | 32 | ||
| 31 | if executable('node') && executable('npm') | 33 | if executable('node') && executable('npm') |
| 32 | let g:ycm_install_command .= ' --tern-completer' | 34 | let g:ycm_install_command .= ' --ts-completer' |
| 33 | endif | 35 | endif |
| 34 | 36 | ||
| 35 | if executable('go') | 37 | if executable('go') |
| 36 | let g:ycm_install_command .= ' --gocode-completer' | 38 | let g:ycm_install_command .= ' --go-completer' |
| 37 | endif | 39 | endif |
| 38 | 40 | ||
| 39 | if executable('rustc') | 41 | if executable('rustc') |
| 40 | let g:ycm_install_command .= ' --rust-completer' | 42 | let g:ycm_install_command .= ' --rust-completer' |
| 41 | endif | 43 | endif |
| 42 | 44 | ||
| 43 | Plug 'Valloric/YouCompleteMe', {'do': g:ycm_install_command} | 45 | Plug 'ycm-core/YouCompleteMe', {'do': g:ycm_install_command} |
| 44 | endif | 46 | endif |
| 45 | 47 | ||
| 46 | if has('nvim') | 48 | if has('nvim') |
| @@ -63,7 +65,8 @@ let mapleader=" " | |||
| 63 | syntax on | 65 | syntax on |
| 64 | filetype plugin indent on | 66 | filetype plugin indent on |
| 65 | 67 | ||
| 66 | cnoreabbrev git Git | 68 | " Expand :git to fugitive's :Git, but only as a whole command |
| 69 | cnoreabbrev <expr> git (getcmdtype() ==# ':' && getcmdline() ==# 'git') ? 'Git' : 'git' | ||
| 67 | 70 | ||
| 68 | " Some vim settings | 71 | " Some vim settings |
| 69 | set number | 72 | set number |
| @@ -76,6 +79,19 @@ set listchars=trail:·,tab:▸\ ,eol:¬ | |||
| 76 | set scrolloff=1 | 79 | set scrolloff=1 |
| 77 | set backspace=indent,eol,start | 80 | set backspace=indent,eol,start |
| 78 | set cursorline | 81 | set cursorline |
| 82 | set hidden | ||
| 83 | set wildmenu | ||
| 84 | |||
| 85 | " Faster gutter updates (signify) and snappier <Esc> in terminal vim | ||
| 86 | set updatetime=100 | ||
| 87 | set ttimeoutlen=10 | ||
| 88 | |||
| 89 | " Persistent undo across sessions | ||
| 90 | if !isdirectory(expand('~/.local/share/vim/undo')) | ||
| 91 | call mkdir(expand('~/.local/share/vim/undo'), 'p', 0700) | ||
| 92 | endif | ||
| 93 | set undofile | ||
| 94 | set undodir=~/.local/share/vim/undo | ||
| 79 | 95 | ||
| 80 | " Set colorscheme when the terminal has 256 color support | 96 | " Set colorscheme when the terminal has 256 color support |
| 81 | try | 97 | try |
| @@ -98,13 +114,28 @@ set smartcase " capital letters = case sensitive | |||
| 98 | " Disable ex mode | 114 | " Disable ex mode |
| 99 | nnoremap Q <Nop> | 115 | nnoremap Q <Nop> |
| 100 | 116 | ||
| 101 | " Save as sudo | 117 | " Save as sudo (abbreviation, so a plain :w never stalls on timeoutlen) |
| 102 | cnoremap w!! w !sudo tee > /dev/null % | 118 | " Note: doesn't work in neovim (sudo can't prompt for a password there); |
| 119 | " use a suda.vim-style plugin if needed. | ||
| 120 | cnoreabbrev <expr> w!! (getcmdtype() ==# ':' && getcmdline() ==# 'w!!') | ||
| 121 | \ ? 'w !sudo tee > /dev/null %' : 'w!!' | ||
| 122 | |||
| 123 | " Remove trailing spaces on save, preserving cursor and search pattern | ||
| 124 | function! StripTrailingWhitespace() | ||
| 125 | if index(['markdown', 'diff'], &filetype) >= 0 | ||
| 126 | return | ||
| 127 | endif | ||
| 128 | let l:view = winsaveview() | ||
| 129 | keeppatterns %s/\s\+$//e | ||
| 130 | call winrestview(l:view) | ||
| 131 | endfunction | ||
| 103 | 132 | ||
| 104 | " Remove training spaces on save | 133 | augroup strip_whitespace |
| 105 | autocmd BufWritePre * :%s/\s\+$//e | 134 | autocmd! |
| 135 | autocmd BufWritePre * call StripTrailingWhitespace() | ||
| 136 | augroup END | ||
| 106 | 137 | ||
| 107 | " Switch windows with <C-W>[direction] | 138 | " Switch windows with <C-[direction]> |
| 108 | nnoremap <C-J> <C-W>j | 139 | nnoremap <C-J> <C-W>j |
| 109 | nnoremap <C-K> <C-W>k | 140 | nnoremap <C-K> <C-W>k |
| 110 | nnoremap <C-H> <C-W>h | 141 | nnoremap <C-H> <C-W>h |
| @@ -131,9 +162,12 @@ nnoremap <silent> <Leader>ml :call AppendModeline()<CR> | |||
| 131 | 162 | ||
| 132 | " NeoVIM specifics | 163 | " NeoVIM specifics |
| 133 | if has('nvim') | 164 | if has('nvim') |
| 134 | nmap <BS> <C-W>h | 165 | nnoremap <BS> <C-W>h |
| 135 | " tnoremap <Esc> <C-\><C-n> | 166 | " tnoremap <Esc> <C-\><C-n> |
| 136 | autocmd TermOpen * setlocal nolist | 167 | augroup nvim_term |
| 168 | autocmd! | ||
| 169 | autocmd TermOpen * setlocal nolist | ||
| 170 | augroup END | ||
| 137 | lua require('claude-code').setup({ window = { position = 'vertical botright' } }) | 171 | lua require('claude-code').setup({ window = { position = 'vertical botright' } }) |
| 138 | endif | 172 | endif |
| 139 | 173 | ||
| @@ -141,10 +175,20 @@ endif | |||
| 141 | if exists("g:plug_home") | 175 | if exists("g:plug_home") |
| 142 | 176 | ||
| 143 | " NERDTree: | 177 | " NERDTree: |
| 144 | " Open NERDTree when no file is specified | 178 | " Open NERDTree when no file is specified; quit when it's the last window |
| 145 | autocmd StdinReadPre * let s:std_in=1 | 179 | augroup nerdtree_auto |
| 146 | autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | 180 | autocmd! |
| 147 | autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | 181 | autocmd StdinReadPre * let s:std_in=1 |
| 182 | autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | ||
| 183 | autocmd BufEnter * if winnr('$') == 1 && &filetype ==# 'nerdtree' | quit | endif | ||
| 184 | augroup END | ||
| 185 | |||
| 186 | " CtrlP: | ||
| 187 | " Use ripgrep for listing files (fast, respects .gitignore) | ||
| 188 | if executable('rg') | ||
| 189 | let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""' | ||
| 190 | let g:ctrlp_use_caching = 0 | ||
| 191 | endif | ||
| 148 | 192 | ||
| 149 | " NERDCommenter: | 193 | " NERDCommenter: |
| 150 | " Pretty comments | 194 | " Pretty comments |
