diff --git a/.gitmodules b/.gitmodules index d31387f..14b7f7a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,7 +27,7 @@ url = https://github.com/tpope/vim-repeat [submodule "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"] path = vim/.vim/pack/utils/start/vim-surround url = https://github.com/tpope/vim-surround diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0c01c0 --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/vim/.vim/init.vim b/vim/.vim/init.vim new file mode 100644 index 0000000..47e37f8 --- /dev/null +++ b/vim/.vim/init.vim @@ -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 diff --git a/vim/.vim/plugin/filetypes.vim b/vim/.vim/plugin/filetypes.vim new file mode 100644 index 0000000..e6b17e9 --- /dev/null +++ b/vim/.vim/plugin/filetypes.vim @@ -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 diff --git a/vim/.vim/plugin/lsp.vim b/vim/.vim/plugin/lsp.vim new file mode 100644 index 0000000..9056a01 --- /dev/null +++ b/vim/.vim/plugin/lsp.vim @@ -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 pumvisible() ? "" : "\" +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 +nnoremap gr :LspRename +nnoremap gh :LspHover diff --git a/vim/.vim/plugin/mappings.vim b/vim/.vim/plugin/mappings.vim new file mode 100644 index 0000000..d61e7d2 --- /dev/null +++ b/vim/.vim/plugin/mappings.vim @@ -0,0 +1,67 @@ +" search/substitute +nnoremap h :nohlsearch +nnoremap %s :%s/\v +nnoremap :s/\v +vnoremap :s/\v +nnoremap / /\v +nnoremap ? ?\v + +" splits +nnoremap Q :waoq +nnoremap +nnoremap S sj +nnoremap V vl + +" fugitive +nnoremap G :tab G +nnoremap g :G + +" 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! +augroup END + +" netrw +nnoremap - :e %:p:h + +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 / /\V + autocmd FileType netrw nnoremap ? ?\V + + autocmd FileType netrw silent! unmap f + autocmd FileType netrw silent! unmap F + autocmd FileType netrw silent! unmap ; + autocmd FileType netrw silent! unmap , + + autocmd FileType netrw nnoremap f :call NetrwJumpToCharRepeat(0, 0) + autocmd FileType netrw nnoremap F :call NetrwJumpToCharRepeat(1, 0) + autocmd FileType netrw nnoremap ; :call NetrwJumpToCharRepeat(0, 1) + autocmd FileType netrw nnoremap , :call NetrwJumpToCharRepeat(1, 1) +augroup END + +" singlechar +let g:singlechar_keylen_warning = 0 +let g:singlechar_static_cursor = 1 diff --git a/vim/.vim/plugin/tabline.vim b/vim/.vim/plugin/tabline.vim new file mode 100644 index 0000000..ec26fb1 --- /dev/null +++ b/vim/.vim/plugin/tabline.vim @@ -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() diff --git a/vim/.vim/plugin/theme.vim b/vim/.vim/plugin/theme.vim new file mode 100644 index 0000000..4c33f3d --- /dev/null +++ b/vim/.vim/plugin/theme.vim @@ -0,0 +1,5 @@ +set termguicolors +packadd everforest +let g:everforest_background = 'medium' +set background=dark +colorscheme everforest diff --git a/vim/.vimrc b/vim/.vimrc new file mode 100644 index 0000000..734d503 --- /dev/null +++ b/vim/.vimrc @@ -0,0 +1 @@ +source ~/.vim/init.vim