diff options
Diffstat (limited to 'conf')
-rw-r--r-- | conf/after/ftplugin/markdown.vim | 1 | ||||
-rw-r--r-- | conf/after/ftplugin/python.vim | 30 | ||||
-rw-r--r-- | conf/keymaps.vim | 187 | ||||
-rw-r--r-- | conf/options.vim | 82 | ||||
-rw-r--r-- | conf/plugins.vim | 131 | ||||
-rw-r--r-- | conf/spell/en.utf-8.add | 11 | ||||
-rw-r--r-- | conf/spell/fr.utf-8.spl | bin | 0 -> 571627 bytes | |||
-rw-r--r-- | conf/spell/fr.utf-8.sug | bin | 0 -> 2324315 bytes |
8 files changed, 442 insertions, 0 deletions
diff --git a/conf/after/ftplugin/markdown.vim b/conf/after/ftplugin/markdown.vim new file mode 100644 index 0000000..bcda2dd --- /dev/null +++ b/conf/after/ftplugin/markdown.vim @@ -0,0 +1 @@ +setlocal spell diff --git a/conf/after/ftplugin/python.vim b/conf/after/ftplugin/python.vim new file mode 100644 index 0000000..41b1d88 --- /dev/null +++ b/conf/after/ftplugin/python.vim @@ -0,0 +1,30 @@ +" Python +let g:lsp_settings = {} +let g:lsp_settings['pylsp-all'] = + \ { + \ 'workspace_config': {'pylsp-all': { + \ 'configurationSources': ['flake8'], + \ 'plugins': { + \ 'pyflakes' : {'enabled': v:false}, + \ 'flake8': {'enabled': v:true}, + \ 'mypy-ls': {'enabled': v:true, 'live_mode': v:false}, + \ 'pylint': {'enabled': v:true}, + \ 'pydocstyle': {'enabled': v:true}, + \ 'pyls_isort': {'enabled': v:true}, + \ 'autopep8': {'enabled': v:false}, + \ 'yapf': {'enabled': v:false}, + \ 'black': {'enabled': v:true}, + \ } + \ }} + \ } + +" Define a custom function that executes :LspDocumentFormat and :!isort +if !exists('*FormatPythonFile') + function! FormatPythonFile() + silent execute '!black %' + silent execute '!isort %' + endfunction +endif +" Remap the custom function to <leader>ldf +nnoremap <leader>ldf :call FormatPythonFile()<CR> + diff --git a/conf/keymaps.vim b/conf/keymaps.vim new file mode 100644 index 0000000..d68b8c4 --- /dev/null +++ b/conf/keymaps.vim @@ -0,0 +1,187 @@ +""""""""""""""""""""""""""""" +" Keymaps +""""""""""""""""""""""""""""" + +let g:mapleader = "\<Space>" +let g:maplocalleader = ',' +nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR> +nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR> + +" Treat long paragraph as a line +map j gj +map k gk + +"""""""""""""""""""" +" Window movement +"""""""""""""""""""" + +" Go to the bottom window +noremap <C-j> <C-w>j + +" Go to the top window +noremap <C-k> <C-w>k + +" Go to the right window +noremap <C-l> <C-w>l + +" Go to the left window +noremap <C-h> <C-w>h + +"""""""""""""""""""""""" +" Remove highlighting +"""""""""""""""""""""""" + +nnoremap <leader>hl :nohlsearch<CR> + +" Save file +nnoremap <C-s> :w!<CR> + +"""""""""""""""""""""""""" +" Buffer +""""""""""""""""""""""""" + +" Close the current buffer +noremap <leader>bd :Bclose<cr>:tabclose<cr>gT + +" Close all the buffers +noremap <leader>ba :bufdo bd<cr> + +" Go to the next buffer +noremap <leader>bn :bnext<cr> + +" Go to the previous buffer +noremap <leader>bp :bprevious<cr> + +"""""""""""""""""""""""""""" +" Tabs +""""""""""""""""""""""""""" + +" Open a new tab +noremap <leader>tn :tabnew<cr> + +" Close all others tab +noremap <leader>to :tabonly<cr> + +" Close current tab page +noremap <leader>tc :tabclose<cr> + +" Move tabs after another +noremap <leader>tm :tabmove + +" Go to the next tab +noremap <leader>t<leader> :tabnext<cr> + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nnoremap <leader>tl :exe "tabn ".g:lasttab<CR> +au TabLeave * let g:lasttab = tabpagenr() + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +noremap <leader>te :tabedit <C-r>=escape(expand("%:p:h"), " ")<cr>/ + +" Switch CWD to the directory of the open buffer +noremap <leader>cd :cd %:p:h<cr>:pwd<cr> + +" Specify the behavior when switching between buffers +try + set switchbuf=useopen,usetab,newtab + set stal=2 +catch +endtry + +" Return to last edit position when opening files (You want this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + +"""""""""""""""""""""""" +" Netrw +""""""""""""""""""""""" + +" Toggle tree view +nnoremap <C-f> :Lexplore<CR> + +"""""""""""""""""""" +" GitGutter +"""""""""""""""""""" + +let g:gitgutter_enabled=1 " Enable by default gitgutter + +" Go to the previous hunk +nnoremap <leader>hp <Plug>(GitGutterPrevHunk) + +" Go to the next hunk +nnoremap <leader>hn <Plug>(GitGutterNextHunk) + +" Enable / Disable GitGutter +nnoremap <leader>ht <Plug>(GitGutterToggle) + +" Stage Hunk in Git +nnoremap <leader>hs <Plug>(GitGutterStageHunk) + +" Undo Hunk +nnoremap <leader>hu <Plug>(GitGutterUndoHunk) + +" Preview Hunk +nnoremap <leader>hP :GitGutterPreviewHunk<CR> + +" Always show the status line +set laststatus=2 + +""""""""""""""""""""" +" Spell +""""""""""""""""""""" + +" Toggle and untoggle spell checking +noremap <leader>ss :setlocal spell!<cr> + +" Next word to spellcheck +noremap <leader>sn ]s + +" Previous word to spellcheck +noremap <leader>sp [s + +" Add word into the spellcheck dictionary +noremap <leader>sa zg + +" show the list of alternatives for the word +noremap <leader>s? z= + +""""""""""""""""""" +" LSP +""""""""""""""""""" +inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" + +" Make <CR> to accept selected completion item or notify coc.nvim to format +" <C-g>u breaks current undo, please make your own choice +inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() + \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" + +nmap <silent> gp <Plug>(coc-diagnostic-prev) +nmap <silent> gn <Plug>(coc-diagnostic-next) + +" GoTo code navigation +nmap <silent> gd <Plug>(coc-definition) +nmap <silent> gy <Plug>(coc-type-definition) +nmap <silent> gi <Plug>(coc-implementation) +nmap <silent> gr <Plug>(coc-references) + +" Use K to show documentation in preview window +nnoremap <silent> gh :call ShowDocumentation()<CR> + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap <leader>gR <Plug>(coc-rename) + +" Formatting selected code +xmap <leader>gf <Plug>(coc-format-selected) +nmap <leader>gf <Plug>(coc-format-selected) diff --git a/conf/options.vim b/conf/options.vim new file mode 100644 index 0000000..6a9e2dc --- /dev/null +++ b/conf/options.vim @@ -0,0 +1,82 @@ +" Search options +set incsearch " Search for partial typed match +set ignorecase " Search not case sensitive +set smartcase " Search for pattern if contains uppercase +set hlsearch " Highlight all match search pattern + +" Graphics options +syntax on " Show syntax color +set number " Show line number +colorscheme onedark " Set vim theme to onedark +set colorcolumn=80 " Add an indicator for 80 char limit +set relativenumber " Show relative line number +set cursorline " Select the current line +set showmatch " Show matching brackets when hovered +set noshowmode " Disable the -- INSERTION -- default comment +set so=7 " Set 7 lines to the cursor - when moving vertically + +" Mouse options +set mouse=a " Allow the mouse to do all the editing + +" Indent options +set tabstop=4 " Size of a tab +set shiftwidth=4 " Number of space for each indent +set softtabstop=0 " Useless indent +set noexpandtab " Vim will automatically use tab and not spaces +set smartindent " Do clever indenting +set copyindent " Copy indent style of the file +" Automatic options +set autowrite " Automatically write the file on certain actions +set autoread " Automatically read external changes on the file + +" System +if has('unnamedplus') " Allow OS & vim clipboard sync + set clipboard=unnamedplus +endif +set undofile " Save undo history +set history=500 " Max line vim remember +set updatetime=500 " Delay before vim write swap file, better for gitgutter + +" Autocomplete +set completeopt=menu,menuone,popup,noselect,noinsert " Show a pop up for + " command completion +set wildmenu " Turn on wildmenu +filetype plugin on + +" Avoid garbled characters in Chinese language windows OS +let $LANG='en' " Setting lang as en +set langmenu=en " Setting menu lang as en +" This delete all the defined menu +source $VIMRUNTIME/delmenu.vim +source $VIMRUNTIME/menu.vim + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" Don't redraw while executing macros (good performance config) +set lazyredraw + +" How many tenths of a second to blink when matching brackets +set mat=2 + +" Set UTF-8 as standard encoding and en_US as the standard language +set encoding=utf8 + +" Use Unix as the standard file type +set ffs=unix,dos,mac + +" Turn backup off, since most stuff is in SVN, git etc. anyway... +set nobackup +set noswapfile + +" Timeout +set timeoutlen=500 diff --git a/conf/plugins.vim b/conf/plugins.vim new file mode 100644 index 0000000..7dd1f9a --- /dev/null +++ b/conf/plugins.vim @@ -0,0 +1,131 @@ +"""""""""""""""""""""""""" +" Plugins +"""""""""""""""""""""""""" +" Install vim-plug if not found +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +endif + +" Run PlugInstall if there are missing plugins +autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + \| PlugInstall --sync | source $MYVIMRC +\| endif + +call plug#begin('~/.vim/plugged') + +" UI & Themes +Plug 'joshdick/onedark.vim' " Onedark themes for vim +Plug 'liuchengxu/vim-which-key' " Show leader mapping cheatsheet + +" Git integration +Plug 'airblade/vim-gitgutter' " Git diff + +" Autocompletion, linter, syntax +Plug 'neoclide/coc.nvim', {'branch': 'release'} + +" Tools +Plug 'wakatime/vim-wakatime' " Wakatime +Plug 'ap/vim-css-color' " rgb, hex color preview + +call plug#end() + +filetype plugin indent on " Allow filetype detection, plugins, indentation + +""""""""""""""""""""""""" +" Configuration +""""""""""""""""""""""""" +" Netrw (filetree built-in vim) +let g:netrw_keepdir = 0 " Reload buffer usefull when moving or removing file +let g:netrw_winsize = 10 " Size of filetree buffer +let g:netrw_banner = 0 " Removing netrw banner +let g:netrw_localcopydircmd = 'cp -r' " Changing copy command to add recursive copy + +" Statusline +let g:currentmode={ + \ 'n' : 'NORMAL ', + \ 'v' : 'VISUAL ', + \ 'V' : 'V·Line ', + \ "\<C-V>" : 'V·Block ', + \ 'i' : 'INSERT ', + \ 'R' : 'R ', + \ 'Rv' : 'V·Replace ', + \ 'c' : 'Command ', + \} +set laststatus=2 +set statusline= +" VIM Mode +set statusline+=\ %{toupper(g:currentmode[mode()])}%{&spell?'[SPELL]':''}\| +" File (path, modified, readonly ? ) +set statusline+=%h\ %F +set statusline+=%{&modified?'\ [+]':''} +set statusline+=%{&readonly?'\ ':''} +" Filetype +set statusline+=%=%y +set statusline+=\ \|\ %{&fileencoding?&fileencoding:&encoding} +set statusline+=\ \|\ [%{&fileformat}\] +" Line count and percentage +set statusline+=\ \|\ %l:%c +set statusline+=\ [%p%%]\ + + +" Which Key +call which_key#register('<Space>', "g:which_key_map") +let g:which_key_map = {} + +" Buffer key help +let g:which_key_map.b = { + \ 'name' : '+buffer', + \ 'd' : 'current buffer close', + \ 'a' : 'close all buffers', + \ 'n' : 'go to next buffer', + \ 'p' : 'go to previous buffer', + \ } + +" Tab key help +let g:which_key_map.t = { + \ 'name' : '+tab', + \ 't<leader>' : 'go to next tab', + \ 'n' : 'open new tab', + \ 'o' : 'close other tabs', + \ 'c' : 'close current tab', + \ 'm' : 'move tab after another', + \ 'l' : 'switch between this & last tab', + \ 'e' : 'open new tab with current buffer', + \ } + +" Spell key help +let g:which_key_map.s = { + \ 'name' : '+spell', + \ 's' : 'toggle spell check', + \ 'n' : 'next spell word', + \ 'p' : 'previous spell word', + \ 'a' : 'add word in dict', + \ '?' : 'list word alternatives', + \ } + +" Hunk key help +let g:which_key_map.h = { + \ 'name' : '+git hunk', + \ 'l' : 'remove highlight', + \ 'p' : 'go previous hunk', + \ 'n' : 'go next hunk', + \ 't' : 'enable/disable gitgutter', + \ 's' : 'stage hunk', + \ 'u' : 'undo hunk', + \ 'P' : 'preview hunk', + \ } + +" LSP key help +let g:which_key_map.g = { + \ 'name' : '+LSP', + \ 'd' : 'go to definition', + \ 'n' : 'next diagnostic', + \ 'p' : 'previous diagnostic', + \ 'r' : 'go to reference', + \ 'R' : 'rename object', + \ 'y' : 'type definition', + \ 'i' : 'go to implementation', + \ 'h' : 'documentation', + \ 'f' : 'format document', + \ } diff --git a/conf/spell/en.utf-8.add b/conf/spell/en.utf-8.add new file mode 100644 index 0000000..283920b --- /dev/null +++ b/conf/spell/en.utf-8.add @@ -0,0 +1,11 @@ +linters +nerdtree +GitGutter +keybinds +onedark +LSP +vscode +autocompleter +linter +neovim +untoggle diff --git a/conf/spell/fr.utf-8.spl b/conf/spell/fr.utf-8.spl Binary files differnew file mode 100644 index 0000000..ff27132 --- /dev/null +++ b/conf/spell/fr.utf-8.spl diff --git a/conf/spell/fr.utf-8.sug b/conf/spell/fr.utf-8.sug Binary files differnew file mode 100644 index 0000000..df555d2 --- /dev/null +++ b/conf/spell/fr.utf-8.sug |