From 44dba6ec58d85f516414a1ed0db1574bc6c70753 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 19 Oct 2020 01:13:16 +0200 Subject: [PATCH] Shuffle nvim config and add py and rs ftplugin --- .config/nvim/ftplugin/python.vim | 23 ++++++ .config/nvim/ftplugin/rust.vim | 10 +++ .config/nvim/init.vim | 126 +++++++++++++++++-------------- 3 files changed, 102 insertions(+), 57 deletions(-) create mode 100644 .config/nvim/ftplugin/python.vim create mode 100644 .config/nvim/ftplugin/rust.vim diff --git a/.config/nvim/ftplugin/python.vim b/.config/nvim/ftplugin/python.vim new file mode 100644 index 0000000..efd4ab2 --- /dev/null +++ b/.config/nvim/ftplugin/python.vim @@ -0,0 +1,23 @@ +set textwidth=79 +colorscheme monotone + +let b:ale_linters=['mypy', 'pyls', 'pylint'] +" Fix syntax with autopep8. +let b:ale_fixers=['autopep8'] +let g:ale_fix_on_save=1 +" Use .venv as a global default +let g:ale_virtualenv_dir_names=['.venv'] + +" disable autocompletion, cause we use deoplete for completion +let g:jedi#completions_enabled=0 +" open the go-to function in split, not another buffer +let g:jedi#use_splits_not_buffers="right" + +let g:deoplete#enable_at_startup=1 +autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif +inoremap pumvisible() ? "\" : "\" + +" Doesn't read this from init.vim, so add it here again +highlight MatchParen cterm=bold ctermbg=DarkCyan ctermfg=none +highlight ALEWarning ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black cterm=Underline +highlight ALEError ctermbg=Red ctermfg=Black guibg=Red guifg=Black cterm=Underline diff --git a/.config/nvim/ftplugin/rust.vim b/.config/nvim/ftplugin/rust.vim new file mode 100644 index 0000000..9dea00d --- /dev/null +++ b/.config/nvim/ftplugin/rust.vim @@ -0,0 +1,10 @@ +colorscheme monotone + +let b:ale_linters=['analyzer'] +" Fix syntax with rustfmt. +let b:ale_fixers=['rustfmt'] +let g:ale_fix_on_save=1 +let g:ale_rust_cargo_use_clippy = 1 + +" 'colorscheme' overrides highlights, so add it here again +highlight MatchParen cterm=bold ctermbg=DarkCyan ctermfg=none diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 8a855eb..ace715f 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -9,28 +9,15 @@ Plug 'jacoborus/tender.vim' Plug 'vim-airline/vim-airline' Plug 'airblade/vim-gitgutter' Plug 'scrooloose/nerdtree' -Plug 'andreypopp/vim-colors-plain' +Plug 'Lokaltog/vim-monotone' call plug#end() -let g:deoplete#enable_at_startup=1 -autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif -inoremap pumvisible() ? "\" : "\" - -" Enable alignment -let g:neoformat_basic_format_align=1 -" Enable tab to spaces conversion -let g:neoformat_basic_format_retab=1 -" Enable trimmming of trailing whitespace -let g:neoformat_basic_format_trim=1 -let g:neoformat_try_formatprg=0 - -" disable autocompletion, cause we use deoplete for completion -let g:jedi#completions_enabled=0 -" open the go-to function in split, not another buffer -let g:jedi#use_splits_not_buffers="right" - - +" Sane defaults. +set mouse= +syntax on +filetype plugin indent on +set omnifunc=syntaxcomplete#Complete set tabstop=4 set softtabstop=4 set shiftwidth=4 @@ -44,30 +31,74 @@ set number set foldmethod=indent set foldlevel=79 -" Lint and check types -let b:ale_linters=['mypy', 'pyls', 'pylint'] +" Toggles on different plugins/modes +noremap :ToggleMouse +inoremap :ToggleMousea +nmap :set nonumber! +nmap :GitGutterBufferToggle +nmap :NERDTreeToggle +set pastetoggle= + +" Enable vimrc files per project +set exrc +" Disable unsafe commands in project vimrc +set secure + +set wildignorecase " Ignore case in command completion +set laststatus=2 " Always show statusline + +" Search settings +set smartcase " If an uppercase letter is the query, be case sensitive +set incsearch " Highlight matches while typing query +set hlsearch " Highlight all search matches + +" Highlight matching brackets +set showmatch +set mps+=<:> " Also, match < and > + + +" COLORS +" Much better with Tomorrow Night Bright color theme set in alacritty +set background=dark +" Monochrome colorscheme config +let g:monotone_color = [120, 100, 70] " Sets theme color to bright green +let g:monotone_secondary_hue_offset = 200 " Offset secondary colors by 200 degrees +let g:monotone_emphasize_comments = 1 " Emphasize comments + +highlight Search ctermfg=Black +highlight Comment ctermfg=Grey +highlight SignColumn ctermbg=236 +highlight LineNr ctermfg=244 +highlight LineNr ctermbg=232 +highlight Folded ctermbg=DarkGreen +highlight Folded ctermfg=Black +highlight MatchParen cterm=bold ctermbg=magenta ctermfg=none + + +" Filetype indents and line lengths +autocmd BufEnter rst,md set textwidth=79 +autocmd BufEnter html,yaml,css set softtabstop=2 shiftwidth=2 + +" Enable alignment +let g:neoformat_basic_format_align=1 +" Enable tab to spaces conversion +let g:neoformat_basic_format_retab=1 +" Enable trimmming of trailing whitespace +let g:neoformat_basic_format_trim=1 +let g:neoformat_try_formatprg=0 + +" Global ALE config +nmap e: ALEDetail +let b:ale_linters=[] " file type linters defined in ftplugin/*.vim let g:ale_lint_on_save=1 let g:ale_list_window_size=20 -" Fix syntax with autopep8. -" let b:ale_fixers=['autopep8'] -" let g:ale_fix_on_save=1 -" Use .venv as a global default -let g:ale_virtualenv_dir_names=['.venv'] - let g:ale_completion_enabled=1 +let g:ale_set_signs = 1 let g:ale_sign_error="✗" let g:ale_sign_warning="⚠" - -" Enable warnings about trailing whitespace for all files. let b:ale_warn_about_trailing_whitespace=1 - -nmap e: ALEDetail - -" ALE colors -highlight ALEWarning ctermbg=Yellow -highlight ALEWarning ctermfg=Black -highlight ALEError ctermbg=DarkRed -highlight ALEError ctermfg=White +highlight ALEWarning ctermbg=Yellow ctermfg=None guibg=Yellow gui=None cterm=Underline +highlight ALEError ctermbg=Red ctermfg=Black cterm=underline " Use TAB to switch between buffers noremap :bn @@ -78,18 +109,7 @@ highlight WhitespaceEOL ctermbg=red guibg=#ab0d0d match WhitespaceEOL /\s\+\%#\@ :let _s=@/:%s/\s\+$//e:let @/=_s -" Much better with Tomorrow Night Bright color theme set in alacritty -set background=dark -" colorscheme plain - -highlight Search ctermfg=Black -highlight Comment ctermfg=Grey -highlight SignColumn ctermbg=236 -highlight LineNr ctermfg=244 -highlight LineNr ctermbg=232 -highlight Folded ctermbg=DarkGreen -highlight Folded ctermfg=Black - +" Git Gutter config highlight GitGutterAdd guibg=#22ff22 guifg=#000000 ctermfg=Green highlight GitGutterChange guibg=#bbbb00 guifg=#000000 ctermfg=Yellow highlight GitGutterDelete guibg=#ff2222 guifg=#000000 ctermfg=DarkRed @@ -101,14 +121,6 @@ let g:gitgutter_sign_removed_first_line='^^' let g:gitgutter_sign_modified_removed='--' let g:gitgutter_map_keys=0 -" Toggles on different plugins/modes -noremap :ToggleMouse -inoremap :ToggleMousea -nmap :set nonumber! -nmap :GitGutterBufferToggle -nmap :NERDTreeToggle -set pastetoggle= - " Maintain undo history between sessions if !isdirectory("/tmp/.vim-undo-dir") call mkdir("/tmp/.vim-undo-dir", "", 0700)