From 64edc2c7c179776b744eb32bd713a09773ada66a Mon Sep 17 00:00:00 2001 From: Blallo Date: Fri, 11 Jun 2021 22:55:32 +0200 Subject: [PATCH] Refactor vimrc --- config/airline.vim | 22 ++ config/ale.vim | 95 +++++++ config/deoplete.vim | 5 + config/fzf.vim | 15 + config/indent.vim | 49 ++++ config/language-client.vim | 30 ++ config/neosnippets.vim | 22 ++ config/nerdtree.vim | 13 + config/plug.vim | 170 ++++++++++++ config/powerline.vim | 2 + config/rg.vim | 44 +++ config/theme.vim | 35 +++ config/vim-go.vim | 6 + config/vim-rooter.vim | 4 + vimrc | 543 ++----------------------------------- 15 files changed, 537 insertions(+), 518 deletions(-) create mode 100644 config/airline.vim create mode 100644 config/ale.vim create mode 100644 config/deoplete.vim create mode 100644 config/fzf.vim create mode 100644 config/indent.vim create mode 100644 config/language-client.vim create mode 100644 config/neosnippets.vim create mode 100644 config/nerdtree.vim create mode 100644 config/plug.vim create mode 100644 config/powerline.vim create mode 100644 config/rg.vim create mode 100644 config/theme.vim create mode 100644 config/vim-go.vim create mode 100644 config/vim-rooter.vim diff --git a/config/airline.vim b/config/airline.vim new file mode 100644 index 0000000..9f4894e --- /dev/null +++ b/config/airline.vim @@ -0,0 +1,22 @@ +" air-line +"let g:airline_powerline_fonts = 1 + +if !exists('g:airline_symbols') && !g:is_tty + let g:airline_symbols = {} + endif + + " unicode symbols + let g:airline_left_sep = '' + let g:airline_left_alt_sep = '' + let g:airline_right_sep = '' + let g:airline_right_alt_sep = '' + let g:airline_symbols.branch = '' + let g:airline_symbols.readonly = '' + let g:airline_symbols.linenr = ''" + " let g:airline_symbols.branch = '⎇' + let g:airline_symbols.paste = 'ρ' + " let g:airline_symbols.paste = 'Þ' + " let g:airline_symbols.paste = '∥' + let g:airline_symbols.whitespace = 'Ξ' + + diff --git a/config/ale.vim b/config/ale.vim new file mode 100644 index 0000000..f12ee94 --- /dev/null +++ b/config/ale.vim @@ -0,0 +1,95 @@ +""" ALE configuration + +let g:ale_sign_error = '->' +let g:ale_sign_warning = '~>' +" let g:ale_sign_error = '✘' +" let g:ale_sign_warning = '⚠' + +if has('nvim') + let s:user_dir = stdpath('config') +else + let s:user_dir = has('win32') ? expand('~/vimfiles') : expand('~/.vim') +endif + +let g:ale_elixir_elixir_ls_release = '/usr/lib/elixir-ls/' + +let g:ale_linters = { +\ 'javascript': ['eslint'], +\ 'typescript': ['tsserver', 'tslint'], +\ 'python': ['pyls', 'pylint'], +\ 'rust': ['rls'], +\ 'elixir': ['elixir-ls'], +\ 'go': ['gopls'], +\ 'json': ['jsonlint'], +\ 'dockerfile': ['hadolint'], +\ 'vala': ['vala-language-server'], +\ 'scss': ['eslint'], +\ 'elm': ['elm_ls'], +\} + +let g:ale_fixers = { +\ 'javascript': ['prettier'], +\ 'typescript': ['prettier'], +\ 'python': ['black', 'pyls'], +\ 'rust': ['rustfmt'], +\ 'elixir': ['mix_format'], +\ 'graphql': ['prettier'], +\ 'perl': ['perltidy'], +\ 'go': ['gofmt'], +\ 'json': ['prettier'], +\ 'vala': ['uncrustify'], +\ 'dart': ['dartfmt'], +\ 'scss': ['prettier'], +\} + +function! s:getValaProjectRoot(buffer) abort + let l:cur_path_abs = fnamemodify(a:buffer, ':p:h') + let l:maybe_doap_file = expand(l:cur_path_abs . s:sep . '*.doap') + if !empty(l:maybe_doap_file) + return l:cur_path_abs + endif + + for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) + if filereadable(expand(l:path . '*.doap')) + return l:path + endif + endfor + + return '' +endfunction + +call ale#linter#Define('vala', { +\ 'name': 'vala-language-server', +\ 'lsp': 'stdio', +\ 'output_stream': 'both', +\ 'executable': '/usr/bin/vala-language-server', +\ 'command': '%e', +\ 'project_root': function('s:getValaProjectRoot'), +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) + +let g:ale_rust_rls_config = { +\ 'rust': { +\ 'clippy_preference': 'on' +\ } +\ } + +let g:ale_echo_msg_error_str = 'Err' +let g:ale_echo_msg_warning_str = 'Warn' +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' + +let g:ale_go_langserver_executable = 'gopls' +" let g:ale_go_revive_executable = '/usr/bin/revive' +" let g:ale_go_revive_options = '-config ~/.vim/revive.toml' + +let g:airline#extensions#ale#enabled = 1 + +let g:ale_completion_enabled = 1 +let g:ale_lint_on_enter = 0 +let g:ale_lint_on_text_changed = 'never' +highlight ALEErrorSign ctermbg=NONE ctermfg=red +highlight ALEWarningSign ctermbg=NONE ctermfg=yellow +let g:ale_linters_explicit = 1 +let g:ale_lint_on_save = 1 +let g:ale_fix_on_save = 1 + diff --git a/config/deoplete.vim b/config/deoplete.vim new file mode 100644 index 0000000..b394393 --- /dev/null +++ b/config/deoplete.vim @@ -0,0 +1,5 @@ +""" deoplete + +" let g:deoplete#sources = {'go': ['deoplete-go'], 'python': ['deoplete-jedi']} +" call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' }) + diff --git a/config/fzf.vim b/config/fzf.vim new file mode 100644 index 0000000..2df0352 --- /dev/null +++ b/config/fzf.vim @@ -0,0 +1,15 @@ +""" FZF + +let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' + +let g:fzf_action = { +\ 'ctrl-t': 'tabedit', +\ 'ctrl-v': 'vsplit', +\ 'ctrl-x': 'split' } +let g:fzf_buffers_jump = 1 + +let g:fzf_commands_expect = 'alt-enter,ctrl-x' + +" disable popup window +" let g:fzf_layout = { 'down': '40%' } + diff --git a/config/indent.vim b/config/indent.vim new file mode 100644 index 0000000..94096a7 --- /dev/null +++ b/config/indent.vim @@ -0,0 +1,49 @@ +""" indentation seek functions + +" Jump to the next or previous line that has the same level or a lower +" level of indentation than the current line. +" +" exclusive (bool): true: Motion is exclusive +" false: Motion is inclusive +" fwd (bool): true: Go to next line +" false: Go to previous line +" lowerlevel (bool): true: Go to line with lower indentation level +" false: Go to line with the same indentation level +" skipblanks (bool): true: Skip blank lines +" false: Don't skip blank lines +function! NextIndent(exclusive, fwd, lowerlevel, skipblanks) + let line = line('.') + let column = col('.') + let lastline = line('$') + let indent = indent(line) + let stepvalue = a:fwd ? 1 : -1 + while (line > 0 && line <= lastline) + let line = line + stepvalue + if ( ! a:lowerlevel && indent(line) == indent || + \ a:lowerlevel && indent(line) < indent) + if (! a:skipblanks || strlen(getline(line)) > 0) + if (a:exclusive) + let line = line - stepvalue + endif + exe line + exe "normal " column . "|" + return + endif + endif + endwhile +endfunction + +" Moving back and forth between lines of same or lower indentation. +nnoremap [l :call NextIndent(0, 0, 0, 1) +nnoremap ]l :call NextIndent(0, 1, 0, 1) +nnoremap [L :call NextIndent(0, 0, 1, 1) +nnoremap ]L :call NextIndent(0, 1, 1, 1) +vnoremap [l :call NextIndent(0, 0, 0, 1)m'gv'' +vnoremap ]l :call NextIndent(0, 1, 0, 1)m'gv'' +vnoremap [L :call NextIndent(0, 0, 1, 1)m'gv'' +vnoremap ]L :call NextIndent(0, 1, 1, 1)m'gv'' +onoremap [l :call NextIndent(0, 0, 0, 1) +onoremap ]l :call NextIndent(0, 1, 0, 1) +onoremap [L :call NextIndent(1, 0, 1, 1) +onoremap ]L :call NextIndent(1, 1, 1, 1) + diff --git a/config/language-client.vim b/config/language-client.vim new file mode 100644 index 0000000..1cd8c5b --- /dev/null +++ b/config/language-client.vim @@ -0,0 +1,30 @@ +""" LanguageClient +" Required for operations modifying multiple buffers like rename. +set hidden + +" let g:LanguageClient_serverCommands = { +" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'], +" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'], +" \ 'python': ['/usr/local/bin/pyls'], +" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'], +" \ } + +let g:LanguageClient_serverCommands = { +\ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'], +\ 'elixir': ['/usr/lib/elixir-ls/language_server.sh'], +\ 'elm': ['/usr/bin/elm-language-server'], +\ 'python': ['/usr/bin/pyls'], +\ 'go': ['/usr/bin/gopls'], +\ } + +let g:LanguageClient_rootMarkers = { +\ 'elm': ['elm.json'], +\ } + +" note that if you are using Plug mapping you should not use `noremap` mappings. +nmap (lcn-menu) +" Or map each action separately +nmap K (lcn-hover) +nmap gd (lcn-definition) +nmap (lcn-rename) + diff --git a/config/neosnippets.vim b/config/neosnippets.vim new file mode 100644 index 0000000..a692265 --- /dev/null +++ b/config/neosnippets.vim @@ -0,0 +1,22 @@ +""" neosnippets + +" Plugin key-mappings. +" Note: It must be "imap" and "smap". It uses mappings. +imap (neosnippet_expand_or_jump) +smap (neosnippet_expand_or_jump) +xmap (neosnippet_expand_target) + +" SuperTab like snippets behavior. +" Note: It must be "imap" and "smap". It uses mappings. +"imap +" \ pumvisible() ? "\" : +" \ neosnippet#expandable_or_jumpable() ? +" \ "\(neosnippet_expand_or_jump)" : "\" +smap neosnippet#expandable_or_jumpable() ? +\ "\(neosnippet_expand_or_jump)" : "\" + +" For conceal markers. +if has('conceal') + set conceallevel=2 concealcursor=niv +endif + diff --git a/config/nerdtree.vim b/config/nerdtree.vim new file mode 100644 index 0000000..8e01ab8 --- /dev/null +++ b/config/nerdtree.vim @@ -0,0 +1,13 @@ +""" NERDTree + +" Close NERDTree automatically after opening a file with it. +let g:NERDTreeQuitOnOpen = 1 +" Use a single click for opening things in NERDTree +let g:NERDTreeMouseMode = 3 +let g:NERDTreeMapActivateNode = '' +let g:NERDTreeIgnore = [ +\ '\.pyc$', +\ '^__pycache__$', +\ '^\.mypy_cache$', +\] + diff --git a/config/plug.vim b/config/plug.vim new file mode 100644 index 0000000..3facc04 --- /dev/null +++ b/config/plug.vim @@ -0,0 +1,170 @@ +" vim-plug init +if empty(glob('~/.vim/autoload/plug.vim')) + system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim') + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +call plug#begin('~/.vim/bundle') + +""" Install Plugs +" clipboard +Plug 'haya14busa/vim-poweryank' + +" undotree +Plug 'mbbill/undotree' + +" vim-fetch +Plug 'wsdjeg/vim-fetch' + +" powerline-vim +Plug 'powerline/powerline' + +" vim-eunuch +Plug 'tpope/vim-eunuch' + +" vim-commentary +Plug 'tpope/vim-commentary' + +" vim-markbar +Plug 'Yilin-Yang/vim-markbar' + +" vim-rooter +Plug 'airblade/vim-rooter' + +" win-resizer +Plug 'simeji/winresizer' + +" Deoplete.vim +Plug 'Shougo/deoplete.nvim' +Plug 'roxma/nvim-yarp' +Plug 'roxma/vim-hug-neovim-rpc' +Plug 'deoplete-plugins/deoplete-go', { 'do': 'make' } +Plug 'deoplete-plugins/deoplete-jedi' +let g:deoplete#enable_at_startup = 1 + +" neosnippets +"Plug 'Shougo/neosnippet.vim' +"Plug 'Shougo/neosnippet-snippets' + +" fzf +Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plug 'junegunn/fzf.vim' + +" Peekaboo +Plug 'junegunn/vim-peekaboo' + +" NERDTree +Plug 'scrooloose/nerdtree' +Plug 'Xuyuanp/nerdtree-git-plugin' + +" NERTCommenter +Plug 'scrooloose/nerdcommenter' + +" tagbar +" Plug 'majutsushi/tagbar' + +" vim-fugitive +Plug 'tpope/vim-fugitive' + +" dadbod (sql) +Plug 'tpope/vim-dadbod' + +" yara +Plug 'yaunj/vim-yara' + +" Dart +" Plug 'bartekd/vim-dart' +Plug 'dart-lang/dart-vim-plugin' + +" Kotlin +Plug 'udalov/kotlin-vim' + +" Elixir +Plug 'elixir-editors/vim-elixir' +" Plug 'GrzegorzKozub/vim-elixirls', { 'do': ':ElixirLsCompileSync' } + +" Elm +"Plug 'elmcast/elm-vim' +"Plug 'andys8/vim-elm-syntax' +"let g:elm_format_autosave = 1 +"Plug 'Zaptic/elm-vim' + +" GraphQL +Plug 'jparise/vim-graphql' + +" Scss +Plug 'cakebaker/scss-syntax.vim' + +" Vala +Plug 'arrufat/vala.vim' + +" ALE +"Plug 'w0rp/ale' +Plug 'dense-analysis/ale' +let g:ale_completion_enabled = 0 + +" LanguageClient +Plug 'autozimu/LanguageClient-neovim', { + \ 'branch': 'next', + \ 'do': 'bash install.sh', + \ } + +" vim-airline +"Plug 'vim-airline/vim-airline' +"Plug 'vim-airline/vim-airline-themes' + +" Colorschemes +Plug 'junegunn/seoul256.vim' +Plug 'scwood/vim-hybrid' +Plug 'kristijanhusak/vim-hybrid-material' +Plug 'srcery-colors/srcery-vim' +Plug 'nightsense/cosmic_latte' +Plug 'rafi/awesome-vim-colorschemes' +Plug 'altercation/vim-colors-solarized' +Plug 'franbach/miramare' +Plug 'sainnhe/edge' +Plug 'ayu-theme/ayu-vim' +Plug 'bitfield/vim-gitgo' +Plug 'savq/melange' +Plug 'sonph/onehalf', { 'rtp': 'vim' } + +" indent-guides +Plug 'nathanaelkane/vim-indent-guides' + +" Dockerfile.vim +Plug 'ekalinin/Dockerfile.vim' + +" YAML +Plug 'mrk21/yaml-vim' + +" Python +Plug 'ambv/black' + +" TOML +Plug 'cespare/vim-toml' + +" Autoclose +Plug 'jiangmiao/auto-pairs' + +" vim-go +Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } + +" vim-multiple-cursor +Plug 'terryma/vim-multiple-cursors' + +" rust.vim +" Plug 'rust-lang/rust.vim' + +" nginx.vim +Plug 'chr4/nginx.vim' + +" typescript + +Plug 'HerringtonDarkholme/yats.vim' +"Plug 'leafgarland/typescript-vim' +Plug 'ianks/vim-tsx' +Plug 'maxmellon/vim-jsx-pretty' +"Plug 'mhartington/nvim-typescript', {'do': './install.sh'} + + +call plug#end() diff --git a/config/powerline.vim b/config/powerline.vim new file mode 100644 index 0000000..114bedb --- /dev/null +++ b/config/powerline.vim @@ -0,0 +1,2 @@ +""" powerline +let g:powerline_pycmd = "py3" diff --git a/config/rg.vim b/config/rg.vim new file mode 100644 index 0000000..59d96fe --- /dev/null +++ b/config/rg.vim @@ -0,0 +1,44 @@ +" ripgrep +" if executable('ug') +" let $FZF_DEFAULT_COMMAND = 'ug' +" set grepprg=ugrep\ -RInk\ -j\ -u\ --tabs=1\ --ignore-files +" set grepformat=%f:%l:%c:%m,%f+%l+%c+%m,%-G%f\\\|%l\\\|%c\\\|%m +" endif +if executable('rg') + let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"' + set grepprg=rg\ --vimgrep + command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape().'| tr -d "\017"', 1, 0) +endif + +" Search in files with ripgrep + preview with bat +function! Fzf_dev() + let l:fzf_files_options = '--preview "bat --style=numbers,changes --color always {2..-1} | head -'.&lines.'"' + + function! s:files() + let l:files = split(system($FZF_DEFAULT_COMMAND), '\n') + return s:format_list(l:files) + endfunction + + function! s:format_list(candidates) + let l:result = [] + for l:candidate in a:candidates + let l:filename = fnamemodify(l:candidate, ':p:t') + let l:icon = ">-" + call add(l:result, printf('%s %s', l:icon, l:candidate)) + endfor + + return l:result + endfunction + + function! s:edit_file(item) + let l:pos = stridx(a:item, ' ') + let l:file_path = a:item[pos+1:-1] + execute 'silent e' l:file_path + endfunction + + call fzf#run({ + \ 'source': files(), + \ 'sink': function('s:edit_file'), + \ 'options': '-m ' . l:fzf_files_options, + \ 'down': '40%' }) +endfunction diff --git a/config/theme.vim b/config/theme.vim new file mode 100644 index 0000000..078d803 --- /dev/null +++ b/config/theme.vim @@ -0,0 +1,35 @@ +""" Themes and colors +if exists('+termguicolors') + let &t_8f = "\[38;2;%lu;%lu;%lum" + let &t_8b = "\[48;2;%lu;%lu;%lum" + set termguicolors +endif + +function! LightOrDarkness() + if &background==?"dark" + set background=light + colorscheme edge + hi Search guibg=Green + elseif &background==?"light" + set background=dark + colorscheme miramare + hi Search guibg=Purple + endif +endfunction + +" Needed for kitty not to f*ck up the background color +let &t_ut='' + +set background=dark +let g:miramare_enable_italic = 0 +let g:miramare_disable_italic_comment = 1 +let g:miramare_transparent_background = 0 +colorscheme miramare +"let g:airline_theme='hybrid' +set number +let g:enable_bold_font = 1 +let g:enable_italic_font = 1 +set laststatus=2 + +" virtualedit +"set virtualedit=all diff --git a/config/vim-go.vim b/config/vim-go.vim new file mode 100644 index 0000000..9947c29 --- /dev/null +++ b/config/vim-go.vim @@ -0,0 +1,6 @@ +""" vim-go +let g:go_highlight_types = 1 +let g:go_highlight_fields = 1 +let g:go_highlight_functions = 1 +let g:go_highlight_function_calls = 1 + diff --git a/config/vim-rooter.vim b/config/vim-rooter.vim new file mode 100644 index 0000000..68a6bf2 --- /dev/null +++ b/config/vim-rooter.vim @@ -0,0 +1,4 @@ +""" vim-rooter + +"let g:rooter_change_directory_for_non_project_files = 'current': + diff --git a/vimrc b/vimrc index 1272b98..b9a41b1 100644 --- a/vimrc +++ b/vimrc @@ -3,523 +3,29 @@ let s:sep = has('win32') ? '\' : '/' " check if in tty let g:is_tty = system('case $(tty) in (/dev/tty[0-9]) echo 1;; (*) echo 0;; esac') -" vim-plug init -if empty(glob('~/.vim/autoload/plug.vim')) - system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim') - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - """ Set python3 path let g:python3_host_prog = "/usr/bin/python" let g:python_host_prog='/usr/bin/python' -call plug#begin('~/.vim/bundle') - -""" Install Plugs -" clipboard -Plug 'haya14busa/vim-poweryank' - -" undotree -Plug 'mbbill/undotree' - -" vim-fetch -Plug 'wsdjeg/vim-fetch' - -" powerline-vim -Plug 'powerline/powerline' - -" vim-eunuch -Plug 'tpope/vim-eunuch' - -" vim-commentary -Plug 'tpope/vim-commentary' - -" vim-markbar -Plug 'Yilin-Yang/vim-markbar' - -" vim-rooter -Plug 'airblade/vim-rooter' - -" win-resizer -Plug 'simeji/winresizer' - -" Deoplete.vim -Plug 'Shougo/deoplete.nvim' -Plug 'roxma/nvim-yarp' -Plug 'roxma/vim-hug-neovim-rpc' -Plug 'deoplete-plugins/deoplete-go', { 'do': 'make' } -Plug 'deoplete-plugins/deoplete-jedi' -let g:deoplete#enable_at_startup = 1 - -" neosnippets -"Plug 'Shougo/neosnippet.vim' -"Plug 'Shougo/neosnippet-snippets' - -" fzf -Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } -Plug 'junegunn/fzf.vim' - -" Peekaboo -Plug 'junegunn/vim-peekaboo' - -" NERDTree -Plug 'scrooloose/nerdtree' -Plug 'Xuyuanp/nerdtree-git-plugin' - -" NERTCommenter -Plug 'scrooloose/nerdcommenter' - -" tagbar -" Plug 'majutsushi/tagbar' - -" vim-fugitive -Plug 'tpope/vim-fugitive' - -" dadbod (sql) -Plug 'tpope/vim-dadbod' - -" yara -Plug 'yaunj/vim-yara' - -" Dart -" Plug 'bartekd/vim-dart' -Plug 'dart-lang/dart-vim-plugin' - -" Kotlin -Plug 'udalov/kotlin-vim' - -" Elixir -Plug 'elixir-editors/vim-elixir' -" Plug 'GrzegorzKozub/vim-elixirls', { 'do': ':ElixirLsCompileSync' } - -" Elm -"Plug 'elmcast/elm-vim' -"Plug 'andys8/vim-elm-syntax' -"let g:elm_format_autosave = 1 -"Plug 'Zaptic/elm-vim' - -" GraphQL -Plug 'jparise/vim-graphql' - -" Scss -Plug 'cakebaker/scss-syntax.vim' - -" Vala -Plug 'arrufat/vala.vim' - -" ALE -"Plug 'w0rp/ale' -Plug 'dense-analysis/ale' -let g:ale_completion_enabled = 0 - -" LanguageClient -Plug 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': 'bash install.sh', - \ } - -" vim-airline -"Plug 'vim-airline/vim-airline' -"Plug 'vim-airline/vim-airline-themes' - -" Colorschemes -Plug 'junegunn/seoul256.vim' -Plug 'scwood/vim-hybrid' -Plug 'kristijanhusak/vim-hybrid-material' -Plug 'srcery-colors/srcery-vim' -Plug 'nightsense/cosmic_latte' -Plug 'rafi/awesome-vim-colorschemes' -Plug 'altercation/vim-colors-solarized' -Plug 'franbach/miramare' -Plug 'sainnhe/edge' -Plug 'ayu-theme/ayu-vim' -Plug 'bitfield/vim-gitgo' -Plug 'savq/melange' -Plug 'sonph/onehalf', { 'rtp': 'vim' } - -" indent-guides -Plug 'nathanaelkane/vim-indent-guides' - -" Dockerfile.vim -Plug 'ekalinin/Dockerfile.vim' - -" YAML -Plug 'mrk21/yaml-vim' - -" Python -Plug 'ambv/black' - -" TOML -Plug 'cespare/vim-toml' - -" Autoclose -Plug 'jiangmiao/auto-pairs' - -" vim-go -Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } - -" vim-multiple-cursor -Plug 'terryma/vim-multiple-cursors' - -" rust.vim -" Plug 'rust-lang/rust.vim' - -" nginx.vim -Plug 'chr4/nginx.vim' - -" typescript - -Plug 'HerringtonDarkholme/yats.vim' -"Plug 'leafgarland/typescript-vim' -Plug 'ianks/vim-tsx' -Plug 'maxmellon/vim-jsx-pretty' -"Plug 'mhartington/nvim-typescript', {'do': './install.sh'} - - -call plug#end() - -""" - -""" vim-rooter - -"let g:rooter_change_directory_for_non_project_files = 'current': - -""" neosnippets - -" Plugin key-mappings. -" Note: It must be "imap" and "smap". It uses mappings. -imap (neosnippet_expand_or_jump) -smap (neosnippet_expand_or_jump) -xmap (neosnippet_expand_target) - -" SuperTab like snippets behavior. -" Note: It must be "imap" and "smap". It uses mappings. -"imap -" \ pumvisible() ? "\" : -" \ neosnippet#expandable_or_jumpable() ? -" \ "\(neosnippet_expand_or_jump)" : "\" -smap neosnippet#expandable_or_jumpable() ? -\ "\(neosnippet_expand_or_jump)" : "\" - -" For conceal markers. -if has('conceal') - set conceallevel=2 concealcursor=niv -endif - -""" LanguageClient -" Required for operations modifying multiple buffers like rename. -set hidden - -" let g:LanguageClient_serverCommands = { -" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'], -" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'], -" \ 'python': ['/usr/local/bin/pyls'], -" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'], -" \ } - -let g:LanguageClient_serverCommands = { -\ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'], -\ 'elixir': ['/usr/lib/elixir-ls/language_server.sh'], -\ 'elm': ['/usr/bin/elm-language-server'], -\ 'python': ['/usr/bin/pyls'], -\ 'go': ['/usr/bin/gopls'], -\ } - -let g:LanguageClient_rootMarkers = { -\ 'elm': ['elm.json'], -\ } - -" note that if you are using Plug mapping you should not use `noremap` mappings. -nmap (lcn-menu) -" Or map each action separately -nmap K (lcn-hover) -nmap gd (lcn-definition) -nmap (lcn-rename) - -""" ALE configuration - -let g:ale_sign_error = '->' -let g:ale_sign_warning = '~>' -" let g:ale_sign_error = '✘' -" let g:ale_sign_warning = '⚠' - -if has('nvim') - let s:user_dir = stdpath('config') -else - let s:user_dir = has('win32') ? expand('~/vimfiles') : expand('~/.vim') -endif - -let g:ale_elixir_elixir_ls_release = '/usr/lib/elixir-ls/' - -let g:ale_linters = { -\ 'javascript': ['eslint'], -\ 'typescript': ['tsserver', 'tslint'], -\ 'python': ['pyls', 'pylint'], -\ 'rust': ['rls'], -\ 'elixir': ['elixir-ls'], -\ 'go': ['gopls'], -\ 'json': ['jsonlint'], -\ 'dockerfile': ['hadolint'], -\ 'vala': ['vala-language-server'], -\ 'scss': ['eslint'], -\ 'elm': ['elm_ls'], -\} - -let g:ale_fixers = { -\ 'javascript': ['prettier'], -\ 'typescript': ['prettier'], -\ 'python': ['black', 'pyls'], -\ 'rust': ['rustfmt'], -\ 'elixir': ['mix_format'], -\ 'graphql': ['prettier'], -\ 'perl': ['perltidy'], -\ 'go': ['gofmt'], -\ 'json': ['prettier'], -\ 'vala': ['uncrustify'], -\ 'dart': ['dartfmt'], -\ 'scss': ['prettier'], -\} - -function! s:getValaProjectRoot(buffer) abort - let l:cur_path_abs = fnamemodify(a:buffer, ':p:h') - let l:maybe_doap_file = expand(l:cur_path_abs . s:sep . '*.doap') - if !empty(l:maybe_doap_file) - return l:cur_path_abs - endif - - for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h')) - if filereadable(expand(l:path . '*.doap')) - return l:path - endif - endfor - - return '' -endfunction - -call ale#linter#Define('vala', { -\ 'name': 'vala-language-server', -\ 'lsp': 'stdio', -\ 'output_stream': 'both', -\ 'executable': '/usr/bin/vala-language-server', -\ 'command': '%e', -\ 'project_root': function('s:getValaProjectRoot'), -\ 'callback': 'ale#handlers#unix#HandleAsWarning', -\}) - -let g:ale_rust_rls_config = { -\ 'rust': { -\ 'clippy_preference': 'on' -\ } -\ } - -let g:ale_echo_msg_error_str = 'Err' -let g:ale_echo_msg_warning_str = 'Warn' -let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' - -let g:ale_go_langserver_executable = 'gopls' -" let g:ale_go_revive_executable = '/usr/bin/revive' -" let g:ale_go_revive_options = '-config ~/.vim/revive.toml' - -let g:airline#extensions#ale#enabled = 1 - -let g:ale_completion_enabled = 1 -let g:ale_lint_on_enter = 0 -let g:ale_lint_on_text_changed = 'never' -highlight ALEErrorSign ctermbg=NONE ctermfg=red -highlight ALEWarningSign ctermbg=NONE ctermfg=yellow -let g:ale_linters_explicit = 1 -let g:ale_lint_on_save = 1 -let g:ale_fix_on_save = 1 - -""" vim-go -let g:go_highlight_types = 1 -let g:go_highlight_fields = 1 -let g:go_highlight_functions = 1 -let g:go_highlight_function_calls = 1 - -""" deoplete - -" let g:deoplete#sources = {'go': ['deoplete-go'], 'python': ['deoplete-jedi']} -" call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' }) - -""" Themes and colors -if exists('+termguicolors') - let &t_8f = "\[38;2;%lu;%lu;%lum" - let &t_8b = "\[48;2;%lu;%lu;%lum" - set termguicolors -endif - -function! LightOrDarkness() - if &background==?"dark" - set background=light - colorscheme edge - hi Search guibg=Green - elseif &background==?"light" - set background=dark - colorscheme miramare - hi Search guibg=Purple - endif -endfunction - -" Needed for kitty not to f*ck up the background color -let &t_ut='' - -set background=dark -let g:miramare_enable_italic = 0 -let g:miramare_disable_italic_comment = 1 -let g:miramare_transparent_background = 0 -colorscheme miramare -"let g:airline_theme='hybrid' -set number -let g:enable_bold_font = 1 -let g:enable_italic_font = 1 -set laststatus=2 - -" virtualedit -"set virtualedit=all - -" air-line -"let g:airline_powerline_fonts = 1 - -if !exists('g:airline_symbols') && !g:is_tty - let g:airline_symbols = {} - endif - - " unicode symbols - let g:airline_left_sep = '' - let g:airline_left_alt_sep = '' - let g:airline_right_sep = '' - let g:airline_right_alt_sep = '' - let g:airline_symbols.branch = '' - let g:airline_symbols.readonly = '' - let g:airline_symbols.linenr = ''" - " let g:airline_symbols.branch = '⎇' - let g:airline_symbols.paste = 'ρ' - " let g:airline_symbols.paste = 'Þ' - " let g:airline_symbols.paste = '∥' - let g:airline_symbols.whitespace = 'Ξ' - - -""" FZF - -let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' - -let g:fzf_action = { -\ 'ctrl-t': 'tabedit', -\ 'ctrl-v': 'vsplit', -\ 'ctrl-x': 'split' } -let g:fzf_buffers_jump = 1 - -let g:fzf_commands_expect = 'alt-enter,ctrl-x' - -" disable popup window -" let g:fzf_layout = { 'down': '40%' } - -""" NERDTree - -" Close NERDTree automatically after opening a file with it. -let g:NERDTreeQuitOnOpen = 1 -" Use a single click for opening things in NERDTree -let g:NERDTreeMouseMode = 3 -let g:NERDTreeMapActivateNode = '' -let g:NERDTreeIgnore = [ -\ '\.pyc$', -\ '^__pycache__$', -\ '^\.mypy_cache$', -\] - -" ripgrep -" if executable('ug') -" let $FZF_DEFAULT_COMMAND = 'ug' -" set grepprg=ugrep\ -RInk\ -j\ -u\ --tabs=1\ --ignore-files -" set grepformat=%f:%l:%c:%m,%f+%l+%c+%m,%-G%f\\\|%l\\\|%c\\\|%m -" endif -if executable('rg') - let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"' - set grepprg=rg\ --vimgrep - command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape().'| tr -d "\017"', 1, 0) -endif - -" Search in files with ripgrep + preview with bat -function! Fzf_dev() - let l:fzf_files_options = '--preview "bat --style=numbers,changes --color always {2..-1} | head -'.&lines.'"' - - function! s:files() - let l:files = split(system($FZF_DEFAULT_COMMAND), '\n') - return s:format_list(l:files) - endfunction - - function! s:format_list(candidates) - let l:result = [] - for l:candidate in a:candidates - let l:filename = fnamemodify(l:candidate, ':p:t') - let l:icon = ">-" - call add(l:result, printf('%s %s', l:icon, l:candidate)) - endfor - - return l:result - endfunction - - function! s:edit_file(item) - let l:pos = stridx(a:item, ' ') - let l:file_path = a:item[pos+1:-1] - execute 'silent e' l:file_path - endfunction - - call fzf#run({ - \ 'source': files(), - \ 'sink': function('s:edit_file'), - \ 'options': '-m ' . l:fzf_files_options, - \ 'down': '40%' }) -endfunction -""" indentation seek functions - -" Jump to the next or previous line that has the same level or a lower -" level of indentation than the current line. -" -" exclusive (bool): true: Motion is exclusive -" false: Motion is inclusive -" fwd (bool): true: Go to next line -" false: Go to previous line -" lowerlevel (bool): true: Go to line with lower indentation level -" false: Go to line with the same indentation level -" skipblanks (bool): true: Skip blank lines -" false: Don't skip blank lines -function! NextIndent(exclusive, fwd, lowerlevel, skipblanks) - let line = line('.') - let column = col('.') - let lastline = line('$') - let indent = indent(line) - let stepvalue = a:fwd ? 1 : -1 - while (line > 0 && line <= lastline) - let line = line + stepvalue - if ( ! a:lowerlevel && indent(line) == indent || - \ a:lowerlevel && indent(line) < indent) - if (! a:skipblanks || strlen(getline(line)) > 0) - if (a:exclusive) - let line = line - stepvalue - endif - exe line - exe "normal " column . "|" - return - endif - endif - endwhile -endfunction - -" Moving back and forth between lines of same or lower indentation. -nnoremap [l :call NextIndent(0, 0, 0, 1) -nnoremap ]l :call NextIndent(0, 1, 0, 1) -nnoremap [L :call NextIndent(0, 0, 1, 1) -nnoremap ]L :call NextIndent(0, 1, 1, 1) -vnoremap [l :call NextIndent(0, 0, 0, 1)m'gv'' -vnoremap ]l :call NextIndent(0, 1, 0, 1)m'gv'' -vnoremap [L :call NextIndent(0, 0, 1, 1)m'gv'' -vnoremap ]L :call NextIndent(0, 1, 1, 1)m'gv'' -onoremap [l :call NextIndent(0, 0, 0, 1) -onoremap ]l :call NextIndent(0, 1, 0, 1) -onoremap [L :call NextIndent(1, 0, 1, 1) -onoremap ]L :call NextIndent(1, 1, 1, 1) +""" source + +" vim-plug has to be on top +source config/plug.vim + +" all other includes are in alphabetical order +source config/airline.vim +source config/ale.vim +source config/deoplete.vim +source config/fzf.vim +source config/indent.vim +source config/language-client.vim +source config/neosnippets.vim +source config/nerdtree.vim +source config/powerline.vim +source config/rg.vim +source config/theme.vim +source config/vim-go.vim +source config/vim-rooter.vim """ general @@ -532,7 +38,7 @@ packloadall silent! helptags ALL " Enable persistent undo -set undodir=$VIMHOME/.undo// +set undodir=$VIMHOME/.undo/ set undofile set undolevels=1000 "maximum number of changes that can be undone set undoreload=10000 "maximum number lines to save for undo on a buffer reload @@ -545,8 +51,8 @@ set autoindent set showmatch " Put all special files in the right place -set backupdir=$VIMHOME/.backup// -set directory=$VIMHOME/.swp// +set backupdir=$VIMHOME/.backup/ +set directory=$VIMHOME/.swp/ " Draw tabs and trailing spaces. " set listchars=tab:<-> @@ -587,8 +93,11 @@ highlight LineHighlight ctermbg=darkgray guibg=Purple " Make :Q and :W work like :q and :w command! W w command! Q q +command! QA qa command! WQ wq command! Wq wq +command! Wqa wqa +command! WQA wqa command! WW w ! sudo tee %:t " Make completion smarter. @@ -618,8 +127,6 @@ if !empty(glob(s:info_filename)) && !filewritable(s:info_filename) echoerr 'The .viminfo file cannot be written to!' endif -""" powerline -let g:powerline_pycmd = "py3" """ keybindings