feat: vim
This commit is contained in:
parent
817ac11b47
commit
75651c8607
9 changed files with 206 additions and 1 deletions
2
.gitmodules
vendored
2
.gitmodules
vendored
|
|
@ -27,7 +27,7 @@
|
||||||
url = https://github.com/tpope/vim-repeat
|
url = https://github.com/tpope/vim-repeat
|
||||||
[submodule "vim/.vim/pack/utils/start/vim-singlechar"]
|
[submodule "vim/.vim/pack/utils/start/vim-singlechar"]
|
||||||
path = vim/.vim/pack/utils/start/vim-singlechar
|
path = vim/.vim/pack/utils/start/vim-singlechar
|
||||||
url = https://git.lohic.dev/loic/vim-singlechar
|
url = forgejo@lohic.dev:loic/vim-singlechar.git
|
||||||
[submodule "vim/.vim/pack/utils/start/vim-surround"]
|
[submodule "vim/.vim/pack/utils/start/vim-surround"]
|
||||||
path = vim/.vim/pack/utils/start/vim-surround
|
path = vim/.vim/pack/utils/start/vim-surround
|
||||||
url = https://github.com/tpope/vim-surround
|
url = https://github.com/tpope/vim-surround
|
||||||
|
|
|
||||||
68
README.md
Normal file
68
README.md
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
# dotfiles
|
||||||
|
|
||||||
|
Managed with [GNU Stow](https://www.gnu.org/software/stow/).
|
||||||
|
|
||||||
|
## Packages
|
||||||
|
|
||||||
|
| Package | Target | Description |
|
||||||
|
|----------|--------------|------------------------------------|
|
||||||
|
| `bash` | `~` | `.bashrc` and `.bashrc.d/` |
|
||||||
|
| `vim` | `~` | `.vimrc` and `.vim/` with plugins |
|
||||||
|
| `portage`| `/etc` | Gentoo portage configuration |
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### 1. Clone
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone --recurse-submodules forgejo@lohic.dev:loic/dotfiles.git ~/Documents/dotfiles
|
||||||
|
cd ~/Documents/dotfiles
|
||||||
|
```
|
||||||
|
|
||||||
|
If already cloned without submodules:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git submodule update --init --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Install stow
|
||||||
|
|
||||||
|
Gentoo:
|
||||||
|
```bash
|
||||||
|
sudo emerge app-admin/stow
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Apply packages
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ~/Documents/dotfiles
|
||||||
|
|
||||||
|
stow bash
|
||||||
|
stow vim
|
||||||
|
sudo stow --target /etc portage
|
||||||
|
```
|
||||||
|
|
||||||
|
## Vim plugins
|
||||||
|
|
||||||
|
Plugins are managed as git submodules in `vim/.vim/pack/`:
|
||||||
|
|
||||||
|
| Plugin | Category |
|
||||||
|
|-------------------------|----------|
|
||||||
|
| vim-lsp | lsp |
|
||||||
|
| asyncomplete.vim | lsp |
|
||||||
|
| asyncomplete-lsp.vim | lsp |
|
||||||
|
| vim-lsp-settings | lsp |
|
||||||
|
| everforest | theme |
|
||||||
|
| vim-polyglot | theme |
|
||||||
|
| fzf.vim | utils |
|
||||||
|
| vim-fugitive | utils |
|
||||||
|
| vim-repeat | utils |
|
||||||
|
| vim-singlechar | utils |
|
||||||
|
| vim-surround | utils |
|
||||||
|
| vim-vinegar | utils |
|
||||||
|
|
||||||
|
To update all plugins:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git submodule update --remote --merge
|
||||||
|
```
|
||||||
13
vim/.vim/init.vim
Normal file
13
vim/.vim/init.vim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
set ts=4 sw=4
|
||||||
|
set wrap!
|
||||||
|
set number
|
||||||
|
set incsearch
|
||||||
|
set cursorline
|
||||||
|
set scrolloff=2
|
||||||
|
set completeopt=menuone,noinsert
|
||||||
|
|
||||||
|
augroup FocusNumbers
|
||||||
|
autocmd!
|
||||||
|
autocmd WinEnter,BufEnter * setlocal relativenumber
|
||||||
|
autocmd WinLeave,BufLeave * setlocal norelativenumber
|
||||||
|
augroup END
|
||||||
6
vim/.vim/plugin/filetypes.vim
Normal file
6
vim/.vim/plugin/filetypes.vim
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
au BufRead,BufNewFile *.h set filetype=c
|
||||||
|
au BufRead,BufNewFile *.hpp set filetype=cpp
|
||||||
|
au BufRead,BufNewFile *.tpp set filetype=cpp
|
||||||
|
au BufRead,BufNewFile *.ts set filetype=typescript
|
||||||
|
au BufRead,BufNewFile *.js set filetype=javascript
|
||||||
|
au BufRead,BufNewFile **/i3/config set filetype=i3config
|
||||||
22
vim/.vim/plugin/lsp.vim
Normal file
22
vim/.vim/plugin/lsp.vim
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
let g:polyglot_disabled = ['tpp']
|
||||||
|
|
||||||
|
if executable('clangd')
|
||||||
|
au User lsp_setup call lsp#register_server({
|
||||||
|
\ 'name': 'clangd',
|
||||||
|
\ 'cmd': ['clangd'],
|
||||||
|
\ 'allowlist': ['c', 'cpp', 'objc', 'objcpp'],
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:lsp_async_completion = 1
|
||||||
|
let g:asyncomplete_auto_popup = 1
|
||||||
|
let g:asyncomplete_auto_completeopt = "menu"
|
||||||
|
inoremap <expr> <Tab> pumvisible() ? "<C-y>" : "\<Tab>"
|
||||||
|
let g:lsp_diagnostics_virtual_text_align = 'after'
|
||||||
|
let g:lsp_diagnostics_virtual_text_prefix = "• "
|
||||||
|
let g:lsp_diagnostics_float_cursor = 0
|
||||||
|
let g:lsp_document_code_action_signs_enabled = 0
|
||||||
|
|
||||||
|
nnoremap gd :LspDefinition<CR>
|
||||||
|
nnoremap gr :LspRename<CR>
|
||||||
|
nnoremap gh :LspHover<CR>
|
||||||
67
vim/.vim/plugin/mappings.vim
Normal file
67
vim/.vim/plugin/mappings.vim
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
" search/substitute
|
||||||
|
nnoremap <silent> <Leader>h :nohlsearch<CR>
|
||||||
|
nnoremap %s :%s/\v
|
||||||
|
nnoremap <C-s> :s/\v
|
||||||
|
vnoremap <C-s> :s/\v
|
||||||
|
nnoremap / /\v
|
||||||
|
nnoremap ? ?\v
|
||||||
|
|
||||||
|
" splits
|
||||||
|
nnoremap <Space>Q :wa<CR><C-w>o<C-w>q
|
||||||
|
nnoremap <Space> <C-w>
|
||||||
|
nnoremap <Space>S <C-w>s<C-w>j
|
||||||
|
nnoremap <Space>V <C-w>v<C-w>l
|
||||||
|
|
||||||
|
" fugitive
|
||||||
|
nnoremap <Space>G :tab G<CR>
|
||||||
|
nnoremap <Space>g :G<CR>
|
||||||
|
|
||||||
|
" terminal / tab commands
|
||||||
|
command -nargs=0 Vt execute "vertical term"
|
||||||
|
command -nargs=0 Nt execute "tabnew %:p:h"
|
||||||
|
|
||||||
|
" man
|
||||||
|
augroup man
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType man nnoremap q :q!<CR>
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" netrw
|
||||||
|
nnoremap - :e %:p:h<CR>
|
||||||
|
|
||||||
|
let g:netrw_last_char = ''
|
||||||
|
let g:netrw_last_reverse = 0
|
||||||
|
|
||||||
|
function! NetrwJumpToCharRepeat(reverse, repeat)
|
||||||
|
if a:repeat && g:netrw_last_char != ''
|
||||||
|
let l:ch = g:netrw_last_char
|
||||||
|
let l:rev = (a:reverse ? !g:netrw_last_reverse : g:netrw_last_reverse)
|
||||||
|
else
|
||||||
|
let l:ch = nr2char(getchar())
|
||||||
|
let l:rev = a:reverse
|
||||||
|
let g:netrw_last_char = l:ch
|
||||||
|
let g:netrw_last_reverse = a:reverse
|
||||||
|
endif
|
||||||
|
let l:pattern = '\c^' . escape(l:ch, '\~[]')
|
||||||
|
call search(l:pattern, l:rev ? 'bW' : 'W')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup netrw_search
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType netrw nnoremap <buffer> / /\V
|
||||||
|
autocmd FileType netrw nnoremap <buffer> ? ?\V
|
||||||
|
|
||||||
|
autocmd FileType netrw silent! unmap <buffer> f
|
||||||
|
autocmd FileType netrw silent! unmap <buffer> F
|
||||||
|
autocmd FileType netrw silent! unmap <buffer> ;
|
||||||
|
autocmd FileType netrw silent! unmap <buffer> ,
|
||||||
|
|
||||||
|
autocmd FileType netrw nnoremap <buffer> f :call NetrwJumpToCharRepeat(0, 0)<CR>
|
||||||
|
autocmd FileType netrw nnoremap <buffer> F :call NetrwJumpToCharRepeat(1, 0)<CR>
|
||||||
|
autocmd FileType netrw nnoremap <buffer> ; :call NetrwJumpToCharRepeat(0, 1)<CR>
|
||||||
|
autocmd FileType netrw nnoremap <buffer> , :call NetrwJumpToCharRepeat(1, 1)<CR>
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" singlechar
|
||||||
|
let g:singlechar_keylen_warning = 0
|
||||||
|
let g:singlechar_static_cursor = 1
|
||||||
23
vim/.vim/plugin/tabline.vim
Normal file
23
vim/.vim/plugin/tabline.vim
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
function! MyTabLine()
|
||||||
|
let s = ''
|
||||||
|
for i in range(tabpagenr('$'))
|
||||||
|
let buflist = tabpagebuflist(i+1)
|
||||||
|
let winnr = tabpagewinnr(i+1)
|
||||||
|
let bufname = bufname(buflist[winnr-1])
|
||||||
|
if bufname =~ '^fugitive://'
|
||||||
|
let tabname = 'Git'
|
||||||
|
else
|
||||||
|
let tabname = fnamemodify(bufname, ':t')
|
||||||
|
if tabname == ''
|
||||||
|
let tabname = '[No Name]'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
let s .= '%' . (i+1) . 'T'
|
||||||
|
let s .= (i+1 == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
|
||||||
|
let s .= ' ' . tabname . ' '
|
||||||
|
endfor
|
||||||
|
let s .= '%#TabLineFill#%T'
|
||||||
|
return s
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
set tabline=%!MyTabLine()
|
||||||
5
vim/.vim/plugin/theme.vim
Normal file
5
vim/.vim/plugin/theme.vim
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
set termguicolors
|
||||||
|
packadd everforest
|
||||||
|
let g:everforest_background = 'medium'
|
||||||
|
set background=dark
|
||||||
|
colorscheme everforest
|
||||||
1
vim/.vimrc
Normal file
1
vim/.vimrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
source ~/.vim/init.vim
|
||||||
Loading…
Add table
Reference in a new issue