From 59c121fc3186f331140fc272aa82d42c137df6ee Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sun, 16 May 2021 15:55:17 +0300 Subject: [PATCH 1/2] [nvim] fix the disappearing intro/welcome screen --- nvim/colors/dotfiles.vim | 2 +- nvim/dotfiles/plugins-list.vim | 1 + nvim/plugin/editing.vim | 9 ++++++++- nvim/plugin/interface.vim | 8 -------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nvim/colors/dotfiles.vim b/nvim/colors/dotfiles.vim index 0a69a98..270e8e1 100644 --- a/nvim/colors/dotfiles.vim +++ b/nvim/colors/dotfiles.vim @@ -54,7 +54,7 @@ hi! link Directory Title call s:hi('Conceal', 0xC, 'NONE', '', '') call s:hi('NonText', 0x3, '', '', '') - hi! link SpecialKey NonText + hi! link SpecialKey Special call s:hi('MatchParen', 'fg', 0x3, '', '') call s:hi('Keyword', 0xE, '', '', '') diff --git a/nvim/dotfiles/plugins-list.vim b/nvim/dotfiles/plugins-list.vim index 7e94fa2..cb6c36c 100644 --- a/nvim/dotfiles/plugins-list.vim +++ b/nvim/dotfiles/plugins-list.vim @@ -55,6 +55,7 @@ " }}} " Programming {{{ + let g:polyglot_disabled = ['sensible'] Plug 'sheerun/vim-polyglot' Plug 'chikamichi/mediawiki.vim' Plug 'ron-rs/ron.vim' diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index 8b2ec27..3b825ba 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -31,6 +31,13 @@ set commentstring=//%s let g:indentLine_showFirstIndentLevel = 1 let g:indentLine_fileTypeExclude = ['text', 'help', 'tutor', 'man'] + augroup vimrc-indentlines-disable + autocmd! + autocmd TermOpen * IndentLinesDisable + " + autocmd VimEnter * if bufname('%') == '' | IndentLinesDisable | endif + augroup END + let g:detectindent_max_lines_to_analyse = 128 let g:detectindent_check_comment_syntax = 1 @@ -51,7 +58,7 @@ set commentstring=//%s " Invisible characters {{{ set list - let &listchars = "tab:\u2192 ,extends:>,precedes:<,eol:\u00ac,trail:\u00b7" + let &listchars = "tab:\u2192 ,extends:>,precedes:<,eol:\u00ac,trail:\u00b7,nbsp:+" let &showbreak = '>' set display+=uhex " }}} diff --git a/nvim/plugin/interface.vim b/nvim/plugin/interface.vim index 48619e1..11671da 100644 --- a/nvim/plugin/interface.vim +++ b/nvim/plugin/interface.vim @@ -137,12 +137,4 @@ endif " }}} -" Terminal {{{ - augroup vimrc-terminal - autocmd! - autocmd TermOpen * IndentLinesDisable - augroup END -" }}} - - nnoremap make From abdb1a736679a7329627e5cb00c2961d6f0246d0 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sun, 16 May 2021 21:01:43 +0300 Subject: [PATCH 2/2] [nvim] fix Polyglot's bundled vim-sleuth (plus a couple of minor edits) And remove detectindent because now I no longer need it. --- nvim/coc-languages/python.vim | 4 ++-- nvim/colors/dotfiles.vim | 7 +++--- nvim/dotfiles/plugins-list.vim | 1 - nvim/init.vim | 40 ++++++++++++++++++++++++++++++++++ nvim/plugin/editing.vim | 15 ------------- 5 files changed, 46 insertions(+), 21 deletions(-) diff --git a/nvim/coc-languages/python.vim b/nvim/coc-languages/python.vim index 20b80e1..49851ad 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:nvim_dotfiles_dir.'/../python/yapf.ini')] +\ 'yapfArgs': ['--style=' . simplify(g:dotfiles_dir.'/python/yapf.ini')] \ }, \ 'linting': { \ 'pylintEnabled': v:false, \ 'flake8Enabled': v:true, -\ 'flake8Args': ['--config=' . simplify(g:nvim_dotfiles_dir.'/../python/flake8.ini')], +\ 'flake8Args': ['--config=' . simplify(g:dotfiles_dir.'/python/flake8.ini')], \ }, \ } diff --git a/nvim/colors/dotfiles.vim b/nvim/colors/dotfiles.vim index 270e8e1..a48e3af 100644 --- a/nvim/colors/dotfiles.vim +++ b/nvim/colors/dotfiles.vim @@ -3,12 +3,14 @@ " Color definitions {{{ - execute 'source' fnameescape(g:nvim_dotfiles_dir.'/../colorschemes/out/vim.vim') + execute 'source' fnameescape(g:dotfiles_dir.'/colorschemes/out/vim.vim') if !&termguicolors && exists('$_COLORSCHEME_TERMINAL') set notermguicolors endif + let s:is_kitty = $TERM ==# 'xterm-kitty' + " }}} " Theme setup {{{ @@ -102,7 +104,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, '', '') @@ -139,7 +141,6 @@ 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 cb6c36c..0f3b104 100644 --- a/nvim/dotfiles/plugins-list.vim +++ b/nvim/dotfiles/plugins-list.vim @@ -15,7 +15,6 @@ 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 diff --git a/nvim/init.vim b/nvim/init.vim index c1f6da4..a1911ba 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,4 +1,5 @@ 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) @@ -16,6 +17,21 @@ 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 @@ -35,3 +51,27 @@ 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 3b825ba..15fce1c 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -38,21 +38,6 @@ 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 - " }}}