diff --git a/nvim/coc-languages/python.vim b/nvim/coc-languages/python.vim index 49851ad..20b80e1 100644 --- a/nvim/coc-languages/python.vim +++ b/nvim/coc-languages/python.vim @@ -5,11 +5,11 @@ let g:coc_filetypes += ['python'] let g:coc_user_config['python'] = { \ 'formatting': { \ 'provider': 'yapf', -\ 'yapfArgs': ['--style=' . simplify(g:dotfiles_dir.'/python/yapf.ini')] +\ 'yapfArgs': ['--style=' . simplify(g:nvim_dotfiles_dir.'/../python/yapf.ini')] \ }, \ 'linting': { \ 'pylintEnabled': v:false, \ 'flake8Enabled': v:true, -\ 'flake8Args': ['--config=' . simplify(g:dotfiles_dir.'/python/flake8.ini')], +\ 'flake8Args': ['--config=' . simplify(g:nvim_dotfiles_dir.'/../python/flake8.ini')], \ }, \ } diff --git a/nvim/colors/dotfiles.vim b/nvim/colors/dotfiles.vim index a48e3af..0a69a98 100644 --- a/nvim/colors/dotfiles.vim +++ b/nvim/colors/dotfiles.vim @@ -3,14 +3,12 @@ " Color definitions {{{ - execute 'source' fnameescape(g:dotfiles_dir.'/colorschemes/out/vim.vim') + execute 'source' fnameescape(g:nvim_dotfiles_dir.'/../colorschemes/out/vim.vim') if !&termguicolors && exists('$_COLORSCHEME_TERMINAL') set notermguicolors endif - let s:is_kitty = $TERM ==# 'xterm-kitty' - " }}} " Theme setup {{{ @@ -56,7 +54,7 @@ hi! link Directory Title call s:hi('Conceal', 0xC, 'NONE', '', '') call s:hi('NonText', 0x3, '', '', '') - hi! link SpecialKey Special + hi! link SpecialKey NonText call s:hi('MatchParen', 'fg', 0x3, '', '') call s:hi('Keyword', 0xE, '', '', '') @@ -104,7 +102,7 @@ call s:hi('CocWarningSign', 'bg', 0xA, '', '') call s:hi('CocInfoSign', 'bg', 0xD, '', '') hi! link CocHintSign CocInfoSign - call s:hi('CocFadeOut', 0x3, '', '', '') + call s:hi('CocFadeOut', 0x3, '', '', '') hi! link CocMarkdownLink Underlined call s:hi('FoldColumn', 0xC, 0x1, '', '') @@ -141,6 +139,7 @@ hi! link ctrlsfMatch Search hi! link ctrlsfLnumMatch ctrlsfMatch + let s:is_kitty = $TERM ==# 'xterm-kitty' let s:spell_fg = s:is_kitty ? '' : 'bg' let s:spell_bg = s:is_kitty ? 'NONE' : '' let s:spell_attr = s:is_kitty ? 'undercurl' : '' diff --git a/nvim/dotfiles/plugins-list.vim b/nvim/dotfiles/plugins-list.vim index 2993e99..f3494cd 100644 --- a/nvim/dotfiles/plugins-list.vim +++ b/nvim/dotfiles/plugins-list.vim @@ -17,6 +17,7 @@ Plug 'tomtom/tcomment_vim' Plug 'tpope/vim-surround' Plug 'Yggdroot/indentLine' + Plug 'idbrii/detectindent' Plug 'henrik/vim-indexed-search' Plug 'andymass/vim-matchup' Plug 'inkarkat/vim-ingo-library' " required by LineJuggler @@ -56,7 +57,6 @@ " }}} " Programming {{{ - let g:polyglot_disabled = ['sensible'] Plug 'sheerun/vim-polyglot' Plug 'chikamichi/mediawiki.vim' Plug 'ron-rs/ron.vim' diff --git a/nvim/init.vim b/nvim/init.vim index a1911ba..c1f6da4 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,5 +1,4 @@ let g:nvim_dotfiles_dir = expand(':p:h') -let g:dotfiles_dir = expand(':p:h:h') let g:vim_ide = get(g:, 'vim_ide', 0) let g:vim_ide_treesitter = get(g:, 'vim_ide_treesitter', 0) @@ -17,21 +16,6 @@ if !filereadable(s:vim_plug_script) autocmd VimEnter * PlugInstall --sync endif -" HACK: Set `shiftwidth` to something unreasonable to make Polyglot's built-in -" indentation detector believe that it's the "default" value. The problem -" comes from the fact that Polyglot bundles vim-sleuth, but executes it in an -" autoload script, which is loaded by an ftdetect script, which is... loaded -" when vim-plug invokes `filetype on`. Thus vim-sleuth is loaded way before -" the primary chunk of my configuration is loaded, so it won't see my -" preferred indentation value, save 8 (Vim's default) to a local variable -" `s:default_shiftwidth` and always assume that some ftplugin explicitly -" modified the shiftwidth to 2 (my real default value) for that particular -" filetype. So instead I use a classic approach to rectify the problem: -" ridiculously hacky workarounds. In any case, blame this commit: -" . -let s:fake_default_shiftwidth = 0 -let &shiftwidth = s:fake_default_shiftwidth - call plug#begin(s:vim_plug_home) Plug 'junegunn/vim-plug' runtime! dotfiles/plugins-list.vim @@ -51,27 +35,3 @@ endif " }}} colorscheme dotfiles - -if exists(':Sleuth') - " HACK: Continuation of the indentation detection hack. Here I first destroy - " Polyglot's vim-sleuth's autocommands, fortunately there is just one, which - " calls `s:detect_indent()` on `BufEnter`. And also registration into tpope's - " statusline plugin, which I don't use, therefore I don't care. - augroup polyglot-sleuth - autocmd! - " HACK: Now I install my own autocommand, which first resets the local - " shiftwidth to the unreasonable value picked above, which vim-sleuth - " internally compares with its local `s:default_shiftwidth`, sees that both - " are the same, and proceeds to execute the indent detection algorithm. - " Boom, my work here is done. - autocmd BufEnter * let &l:shiftwidth = s:fake_default_shiftwidth | Sleuth - augroup END - - " HACK: In case you are wondering why I'm using Polyglot's bundled vim-sleuth - " given that it requires those terrible hacks to function normally and respect - " my configs, and not something like - " (this is a fork I used to use and which checks syntax groups to improve - " detection quality). ...Well, frankly, even though vim-sleuth's detector uses - " unreliable (at first glance) regex heuristics, in practice it still works - " better than detectindent's syntax group querying. -endif diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index 15fce1c..62b7c4c 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -38,12 +38,27 @@ set commentstring=//%s autocmd VimEnter * if bufname('%') == '' | IndentLinesDisable | endif augroup END + let g:detectindent_max_lines_to_analyse = 128 + let g:detectindent_check_comment_syntax = 1 + + function s:DetectIndent() + if !empty(&bt) | return | endif + let g:detectindent_preferred_indent = &l:shiftwidth + let g:detectindent_preferred_expandtab = &l:expandtab + DetectIndent + endfunction + + augroup vimrc-detect-indent + autocmd! + autocmd BufReadPost * call s:DetectIndent() + augroup END + " }}} " Invisible characters {{{ set list - let &listchars = "tab:\u2192 ,extends:>,precedes:<,eol:\u00ac,trail:\u00b7,nbsp:+" + let &listchars = "tab:\u2192 ,extends:>,precedes:<,eol:\u00ac,trail:\u00b7" let &showbreak = '>' set display+=uhex " }}}