Replace deoplete with nvim-cmp and a collection of autocompletion sources, and refactor a bunch of the config

This commit is contained in:
Kevin MacMartin 2024-03-04 14:39:06 -05:00
parent 42522910e4
commit 3249d3ddf1
21 changed files with 180 additions and 97 deletions

30
.gitmodules vendored
View file

@ -52,12 +52,6 @@
[submodule "vim/bundle/lightline-ale"] [submodule "vim/bundle/lightline-ale"]
path = vim/bundle/lightline-ale path = vim/bundle/lightline-ale
url = https://github.com/maximbaz/lightline-ale url = https://github.com/maximbaz/lightline-ale
[submodule "vim/bundle/deoplete.nvim"]
path = vim/bundle/deoplete.nvim
url = https://github.com/Shougo/deoplete.nvim
[submodule "vim/bundle/neco-syntax"]
path = vim/bundle/neco-syntax
url = https://github.com/Shougo/neco-syntax.git
[submodule "vim/bundle/vim-gutentags"] [submodule "vim/bundle/vim-gutentags"]
path = vim/bundle/vim-gutentags path = vim/bundle/vim-gutentags
url = https://github.com/ludovicchabant/vim-gutentags.git url = https://github.com/ludovicchabant/vim-gutentags.git
@ -70,3 +64,27 @@
[submodule "vim/bundle/nvim-treesitter"] [submodule "vim/bundle/nvim-treesitter"]
path = vim/bundle/nvim-treesitter path = vim/bundle/nvim-treesitter
url = https://github.com/nvim-treesitter/nvim-treesitter url = https://github.com/nvim-treesitter/nvim-treesitter
[submodule "vim/bundle/nvim-cmp"]
path = vim/bundle/nvim-cmp
url = https://github.com/hrsh7th/nvim-cmp
[submodule "vim/bundle/nvim-snippy"]
path = vim/bundle/nvim-snippy
url = https://github.com/dcampos/nvim-snippy
[submodule "vim/bundle/vim-snippets"]
path = vim/bundle/vim-snippets
url = https://github.com/honza/vim-snippets
[submodule "vim/bundle/cmp-treesitter"]
path = vim/bundle/cmp-treesitter
url = https://github.com/ray-x/cmp-treesitter
[submodule "vim/bundle/cmp-nvim-tags"]
path = vim/bundle/cmp-nvim-tags
url = https://github.com/quangnguyen30192/cmp-nvim-tags
[submodule "vim/bundle/cmp-snippy"]
path = vim/bundle/cmp-snippy
url = https://github.com/dcampos/cmp-snippy
[submodule "vim/bundle/cmp-buffer"]
path = vim/bundle/cmp-buffer
url = https://github.com/hrsh7th/cmp-buffer
[submodule "vim/bundle/cmp-omni"]
path = vim/bundle/cmp-omni
url = https://github.com/hrsh7th/cmp-omni

View file

@ -32,7 +32,15 @@ if &term != "linux"
endif endif
"load user config: "load user config:
runtime local/user.vim runtime user.vim
"set default values for user settings
let g:autostartchecker = get(g:, "autostartchecker", 0)
let g:autostarttagbar = get(g:, "autostarttagbar", 0)
let g:enabletreesitter = get(g:, "enabletreesitter", 0)
let g:enablecompletion = get(g:, "enablecompletion", 0)
let g:enableautotags = get(g:, "enableautotags", 0)
let g:enablepowerline = get(g:, "enablepowerline", 0)
"load settings: "load settings:
runtime config/settings.vim runtime config/settings.vim
@ -40,44 +48,21 @@ runtime config/settings.vim
"initialize plugins: "initialize plugins:
let g:pathogen_disabled = get(g:, "pathogen_disabled", []) let g:pathogen_disabled = get(g:, "pathogen_disabled", [])
if has('python3') "don't load vim-gutentags if g:enableautotags is false or ctags isn't in path
"check for python-neovim if !g:enableautotags || !executable('ctags')
redir => python_neovim_check
silent python3 exec("import pkgutil\nneovim = pkgutil.find_loader('neovim')\nfound = neovim is not None\nprint(found)")
redir END
if substitute(python_neovim_check, '^\n*\([^\n]*\)\n*$', '\1', '') == 'True'
let g:python_neovim = 1
else
let g:python_neovim = 0
endif
"check for python-msgpack
redir => python_msgpack_check
silent python3 exec("import pkgutil\nmsgpack = pkgutil.find_loader('msgpack')\nfound = msgpack is not None\nprint(found)")
redir END
if substitute(python_msgpack_check, '^\n*\([^\n]*\)\n*$', '\1', '') == 'True'
let g:python_msgpack = 1
else
let g:python_msgpack = 0
endif
else
"if python isn't available disable plugins that depend on it and set library variables to false
call add(g:pathogen_disabled, 'MatchTagAlways')
let g:python_neovim = 0
let g:python_msgpack = 0
endif
"don't load vim-gutentags if ctags can't be found
if !executable('ctags')
call add(g:pathogen_disabled, 'vim-gutentags') call add(g:pathogen_disabled, 'vim-gutentags')
endif endif
if !g:python_neovim || !g:python_msgpack "don't load nvim-cmp or its dependencies if g:enablecompletion is false
"don't load deoplete if either of its python dependencies are missing if !g:enablecompletion
call add(g:pathogen_disabled, 'deoplete.nvim') call add(g:pathogen_disabled, 'nvim-cmp')
call add(g:pathogen_disabled, 'neco-syntax') call add(g:pathogen_disabled, 'cmp-buffer')
call add(g:pathogen_disabled, 'cmp-nvim-tags')
call add(g:pathogen_disabled, 'cmp-omni')
call add(g:pathogen_disabled, 'cmp-snippy')
call add(g:pathogen_disabled, 'cmp-treesitter')
call add(g:pathogen_disabled, 'nvim-snippy')
call add(g:pathogen_disabled, 'vim-snippets')
endif endif
"use pathogen to load plugins that haven't been disabled "use pathogen to load plugins that haven't been disabled

View file

@ -11,12 +11,9 @@ A theme, config and collection of plugins for Neovim
## Optional Requirements ## Optional Requirements
* **Compilers, Linters and Runtimes**: The ale plugin can use compilers, linters and runtimes to provide real-time syntax checking * **Powerline Fonts**: Required to enable the fancier looking status line
* **CTags**: Required by _tagbar_ and optional for _coc.nvim_ ([ctags website](http://ctags.sourceforge.net)) * **Universal CTags**: Required by _vim-gutentags_, _tagbar_ and optional for _nvim-cmp_
* **Powerline Fonts**: Required to enable the fancier looking status line ([powerline-fonts repo](https://github.com/Lokaltog/powerline-fonts)) * **Compilers, Linters and Runtimes**: The _ale_ plugin can use compilers, linters and runtimes to provide real-time syntax checking
* **Python**: Required for _deoplete_ autocompletion functionality
* **Neovim Python Module**: Required for _deoplete_ autocompletion
* **Python Msgpack**: Required for _deoplete_ autocompletion
## Distribution Features ## Distribution Features
@ -120,11 +117,17 @@ For a complete list of mappings specific to **darkcloud-nvimconfig**, check the
* [ale](https://github.com/w0rp/ale): Asynchronous Lint Engine * [ale](https://github.com/w0rp/ale): Asynchronous Lint Engine
* [Comment.nvim](https://github.com/numToStr/Comment.nvim): Smart and Powerful commenting plugin for neovim * [Comment.nvim](https://github.com/numToStr/Comment.nvim): Smart and Powerful commenting plugin for neovim
* [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring): A Neovim plugin for setting the commentstring option based on the cursor location in the file. The location is checked via treesitter queries * [nvim-ts-context-commentstring](https://github.com/JoosepAlviste/nvim-ts-context-commentstring): A Neovim plugin for setting the commentstring option based on the cursor location in the file. The location is checked via treesitter queries
* [deoplete.nvim](https://github.com/Shougo/deoplete.nvim): Dark powered asynchronous completion framework for neovim/Vim8
* [neco-syntax](https://github.com/Shougo/neco-syntax): Syntax source for neocomplete/deoplete/ncm
* [editorconfig-vim](https://github.com/editorconfig/editorconfig-vim): EditorConfig plugin for Vim that auto-configures certain settings when a .editorconfig file is present * [editorconfig-vim](https://github.com/editorconfig/editorconfig-vim): EditorConfig plugin for Vim that auto-configures certain settings when a .editorconfig file is present
* [lightline.vim](https://github.com/itchyny/lightline.vim): A light and configurable statusline/tabline for Vim * [lightline.vim](https://github.com/itchyny/lightline.vim): A light and configurable statusline/tabline for Vim
* [lightline-ale](https://github.com/maximbaz/lightline-ale): Provides ALE indicator for the lightline vim plugin * [lightline-ale](https://github.com/maximbaz/lightline-ale): Provides ALE indicator for the lightline vim plugin
* [nvim-cmp](https://github.com/hrsh7th/nvim-cmp): A completion engine plugin for neovim written in Lua
* [cmp-buffer](https://github.com/hrsh7th/cmp-buffer): Buffer words source for nvim-cmp
* [cmp-nvim-tags](https://github.com/quangnguyen30192/cmp-nvim-tags): Tags source for nvim-cmp
* [cmp-omni](https://github.com/hrsh7th/cmp-omni): Omnifunc source for cmp-nvim
* [cmp-snippy](https://github.com/dcampos/cmp-snippy): Nvim-snippy completion source for nvim-cmp
* [cmp-treesitter](https://github.com/ray-x/cmp-treesitter): Treesitter source for nvim-cmp
* [nvim-snippy](https://github.com/dcampos/nvim-snippy): Snippet plugin for Neovim written in Lua
* [vim-snippets](https://github.com/honza/vim-snippets): Snippets files for various programming languages
* [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter): Treesitter configurations and abstraction layer for Neovim * [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter): Treesitter configurations and abstraction layer for Neovim
* [ReplaceWithRegister](https://github.com/vim-scripts/ReplaceWithRegister): Replace text with the contents of a register (for paste+replace without writing over the buffer) * [ReplaceWithRegister](https://github.com/vim-scripts/ReplaceWithRegister): Replace text with the contents of a register (for paste+replace without writing over the buffer)
* [splitjoin.vim](https://github.com/AndrewRadev/splitjoin.vim): Simplifies the transition between multiline and single-line code * [splitjoin.vim](https://github.com/AndrewRadev/splitjoin.vim): Simplifies the transition between multiline and single-line code

26
update
View file

@ -17,7 +17,7 @@ local_bundle_dir=local/bundle
error_log=update-errors.log error_log=update-errors.log
script_name="${0//*\/}" script_name="${0//*\/}"
script_home="${0%$script_name}" script_home="${0%"$script_name"}"
if [[ -z "$script_home" ]]; then if [[ -z "$script_home" ]]; then
script_home="$PWD" script_home="$PWD"
@ -70,6 +70,16 @@ function show_help {
printf '%s\n' 'Run with no arguments to update darkcloud-nvimconfig' printf '%s\n' 'Run with no arguments to update darkcloud-nvimconfig'
} }
# update coq_nvim dependencies
function update_coq_dependencies {
coq_nvim_bundle=vim/bundle/coq_nvim
[[ -d "$coq_nvim_bundle" ]] || return 1
pushd "$coq_nvim_bundle" >/dev/null || return 1
python3 -m coq deps >/dev/null 2>&1 || error 'python3 -m coq deps' 'Updating COQ dependencies failed'
popd >/dev/null || return 1
return 0
}
# #
# SETUP # SETUP
# #
@ -301,6 +311,20 @@ else
error "nvim -c ':UpdateRemotePlugins|qa!'" 'Updating remote plugins for neovim failed' error "nvim -c ':UpdateRemotePlugins|qa!'" 'Updating remote plugins for neovim failed'
fi fi
#
# INSTALL/UPDATE COQ DEPENDENCIES
#
printf '%s' "$cbg_blue >> Updating coq_nvim dependencies:$c_reset"
update_coq_dependencies
if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else
printf '%s\n' "$cfg_red_bold FAIL! $c_reset"
error 'python3 -m coq deps' 'Updating coq_nvim dependencies failed'
fi
# #
# FINISH # FINISH
# #

1
vim/bundle/cmp-buffer Submodule

@ -0,0 +1 @@
Subproject commit 3022dbc9166796b644a841a02de8dd1cc1d311fa

@ -0,0 +1 @@
Subproject commit 30bdc2eec86eb66730af541bb06d24d4a67e3eeb

1
vim/bundle/cmp-omni Submodule

@ -0,0 +1 @@
Subproject commit 4ef610bbd85a5ee4e97e09450c0daecbdc60de86

1
vim/bundle/cmp-snippy Submodule

@ -0,0 +1 @@
Subproject commit 6e39210aa3a74e2bf6462f492eaf0d436cd2b7d3

@ -0,0 +1 @@
Subproject commit 13e4ef8f4dd5639fca2eb9150e68f47639a9b37d

@ -1 +0,0 @@
Subproject commit 00a179968eb5f53408dafc22567c1e2933c01079

@ -1 +0,0 @@
Subproject commit f8d7b748b022aac8ce73458574da5616f1c5fb65

1
vim/bundle/nvim-cmp Submodule

@ -0,0 +1 @@
Subproject commit 04e0ca376d6abdbfc8b52180f8ea236cbfddf782

@ -0,0 +1 @@
Subproject commit 6295b6cb30725c343a8986096c9f04b0e7646c52

@ -1 +1 @@
Subproject commit a07a3e86ea173dd71525ee8a6fb0fcc58122cd87 Subproject commit 25afe7ebbc7c34f711685f5d29308a82ed5350ac

@ -0,0 +1 @@
Subproject commit 393d980157b8149b3ff65a48bc4aae24dca9c846

View file

@ -1,5 +1,5 @@
"autostart syntax checking when vim opens to a compatible filetype (default: 0) "always disable ale in diff mode
if !exists("g:autostartchecker") || &diff if &diff
let g:autostartchecker = 0 let g:autostartchecker = 0
endif endif

View file

@ -1,8 +0,0 @@
"enable completion (default: 0)
if !exists("g:enablecompletion")
let g:enablecompletion = 0
endif
if !g:enablecompletion && g:python_neovim
let g:deoplete#enable_at_startup = 1
endif

View file

@ -0,0 +1,55 @@
if (vim.g.enablecompletion == 1) then
local snippy = require("snippy")
local cmp = require"cmp"
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup({
snippet = {
expand = function(args)
require "snippy".expand_snippet(args.body)
end
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif snippy.can_expand_or_advance() then
snippy.expand_or_advance()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif snippy.can_jump(-1) then
snippy.previous()
else
fallback()
end
end, { "i", "s" }),
["<Leader>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = "buffer" },
{ name = "treesitter" },
{ name = "omni" },
{ name = "tags", option = { current_buffer_only = true } },
{ name = "snippy" },
})
})
end

View file

@ -1,26 +1,24 @@
if (vim.g.enabletreesitter ~= nill) then if (vim.g.enabletreesitter == 1) then
if (vim.g.enabletreesitter == 1) then local parser_dir
local parser_dir
if (vim.g.treesitterparserdir == nill) then if (vim.g.treesitterparserdir == nill) then
parser_dir = "~/.config/nvim/treesitter-parsers" parser_dir = "~/.config/nvim/treesitter-parsers"
else else
parser_dir = vim.g.treesitterparserdir parser_dir = vim.g.treesitterparserdir
end
vim.opt.runtimepath:append(parser_dir)
require'nvim-treesitter.configs'.setup {
ensure_installed = { "bash", "c", "cpp", "git_config", "html", "java", "javascript", "json", "lua", "php", "python", "query", "rust", "toml", "typescript", "vim", "vue" },
sync_install = false,
auto_install = false,
parser_install_dir = parser_dir,
highlight = {
enable = true,
disable = {},
additional_vim_regex_highlighting = false,
}
}
end end
vim.opt.runtimepath:append(parser_dir)
require'nvim-treesitter.configs'.setup {
ensure_installed = { "bash", "c", "cpp", "git_config", "html", "java", "javascript", "json", "lua", "php", "python", "query", "rust", "toml", "typescript", "vim", "vue" },
sync_install = false,
auto_install = false,
parser_install_dir = parser_dir,
highlight = {
enable = true,
disable = {},
additional_vim_regex_highlighting = false,
}
}
end end

View file

@ -1,9 +1,5 @@
"autostart tagbar when vim opens to a compatible filetype (default: 0) "start the tagbar if g:autostarttagbar is true while not in diff mode
if !exists("g:autostarttagbar") if g:autostarttagbar == 1 && !&diff
let g:autostarttagbar = 0
endif
if !&diff && (g:autostarttagbar == 1)
autocmd VimEnter * nested :call tagbar#autoopen(1) autocmd VimEnter * nested :call tagbar#autoopen(1)
endif endif

View file

@ -1,12 +1,18 @@
let g:gutentags_cache_dir = get(g:, "gutentags_cache_dir", "~/.config/nvim/gutentags") let g:gutentags_cache_dir = get(g:, "gutentags_cache_dir", "~/.config/nvim/gutentags")
let g:gutentags_ctags_exclude = [
\ '*.json',
\ '*.lock',
\ '*.min.*',
\ 'node_modules/*',
\ 'vendor/*',
\ ]
let g:gutentags_file_list_command = { let g:gutentags_file_list_command = {
\ 'markers': { \ 'markers': {
\ '.git': 'git ls-files', \ '.git': 'git ls-files',
\ }, \ },
\ } \ }
"prevent automatically generating the tagfile and syntax highlighting tags (default: 0) "prevent automatically generating the tagfile and syntax highlighting tags (default: 0)
if !exists("g:enableautotags") || g:enableautotags == 0 let g:gutentags_enabled = g:enableautotags
let g:gutentags_enabled = 0
endif