Trying to get cmp completion plugin to work

This commit is contained in:
Jeremy Wall 2023-07-24 15:42:28 -04:00
parent 4478387b93
commit 1c9bf7056c
3 changed files with 98 additions and 36 deletions

View File

@ -84,7 +84,13 @@ EOF";
packer-nvim packer-nvim
vim-lsp vim-lsp
vim-vsnip vim-vsnip
coq_nvim nvim-cmp
cmp-nvim-lua
cmp-nvim-lsp
cmp-vsnip
cmp-buffer
cmp-path
cmp-nvim-lsp-signature-help
vimspector vimspector
vimagit vimagit
hoon-vim hoon-vim

View File

@ -1,7 +1,7 @@
-- theming -- theming
-- Default options -- Default options
vim.opt.termguicolors = true --vim.opt.termguicolors = true
vim.cmd.colorscheme 'duskfox' --vim.cmd.colorscheme 'duskfox'
-- turn on relative line numbers -- turn on relative line numbers
vim.opt.relativenumber = true vim.opt.relativenumber = true
@ -52,7 +52,61 @@ vim.cmd([[
au BufNewFile,BufRead *.hrl filetype indent off au BufNewFile,BufRead *.hrl filetype indent off
]]) ]])
----Set completeopt to have a better completion experience
---- :help completeopt
---- menuone: popup even when there's only one match
---- noinsert: Do not insert text until a selection is made
---- noselect: Do not select, force to select one from the menu
---- shortness: avoid showing extra messages when using completion
---- updatetime: set updatetime for CursorHold
--vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'}
--vim.opt.shortmess = vim.opt.shortmess + { c = true}
--vim.api.nvim_set_option('updatetime', 300)
--
--https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md --https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
-- TODO(jwall): See about proper snippet support (ie. license comments?)
local cmp = require('cmp')
cmp.setup({
-- Enable LSP snippets
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = cmp.mapping.preset.insert(),
-- Installed sources:
sources = cmp.config.sources(
{
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
},
{
{ name = 'path' }, -- file paths
},
{
{ name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = {'menu', 'abbr', 'kind'},
format = function(entry, item)
local menu_icon ={
nvim_lsp = 'λ',
vsnip = '',
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
})
local caps = vim.tbl_deep_extend( local caps = vim.tbl_deep_extend(
'force', 'force',
@ -61,6 +115,8 @@ local caps = vim.tbl_deep_extend(
); );
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Nix language server support -- Nix language server support
lspconfig.nil_ls.setup{} lspconfig.nil_ls.setup{}
@ -105,7 +161,9 @@ lspconfig.java_language_server.setup{}
lspconfig.tsserver.setup{} lspconfig.tsserver.setup{}
-- Rust language server support -- Rust language server support
lspconfig.rust_analyzer.setup{} lspconfig.rust_analyzer.setup{
capabilities = capabilities
}
-- lua language server setup. -- lua language server setup.
lspconfig.lua_ls.setup{ lspconfig.lua_ls.setup{
@ -196,8 +254,6 @@ vim.cmd([[
let g:coq_settings = { 'auto_start': 'shut-up', 'display.icons.mode': "none" } let g:coq_settings = { 'auto_start': 'shut-up', 'display.icons.mode': "none" }
]]) ]])
require("coq")
--Set completeopt to have a better completion experience --Set completeopt to have a better completion experience
-- :help completeopt -- :help completeopt
-- menuone: popup even when there's only one match -- menuone: popup even when there's only one match

60
nix/darwin/flake.lock generated
View File

@ -7,11 +7,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1684153753, "lastModified": 1690228878,
"narHash": "sha256-PVbWt3qrjYAK+T5KplFcO+h7aZWfEj1UtyoKlvcDxh0=", "narHash": "sha256-9Xe7JV0krp4RJC9W9W9WutZVlw6BlHTFMiUP/k48LQY=",
"owner": "ryantm", "owner": "ryantm",
"repo": "agenix", "repo": "agenix",
"rev": "db5637d10f797bb251b94ef9040b237f4702cde3", "rev": "d8c973fd228949736dedf61b7f8cc1ece3236792",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -34,12 +34,12 @@
}, },
"locked": { "locked": {
"lastModified": 1, "lastModified": 1,
"narHash": "sha256-zUkrSqkKiphniy9Dv8MJpsJKt4HMEoPIpoW6SQyzeOQ=", "narHash": "sha256-uA4sSuHPv0RuNibC98a+mBh/GnMS1vXrwFIE1XP8AIs=",
"path": "/nix/store/f9c9966csi39qz43kg1j16w3phnkdj4d-source/nix/base-system", "path": "/nix/store/pzjnc2vf0y96kai86a1m9m54m33lxwpq-source/nix/base-system",
"type": "path" "type": "path"
}, },
"original": { "original": {
"path": "/nix/store/f9c9966csi39qz43kg1j16w3phnkdj4d-source/nix/base-system", "path": "/nix/store/pzjnc2vf0y96kai86a1m9m54m33lxwpq-source/nix/base-system",
"type": "path" "type": "path"
} }
}, },
@ -71,11 +71,11 @@
"nixpkgs": "nixpkgs_6" "nixpkgs": "nixpkgs_6"
}, },
"locked": { "locked": {
"lastModified": 1687691275, "lastModified": 1692248770,
"narHash": "sha256-VVywT8ubStvDPF5TscDBokT3T0l3zsOzCW056noh5zc=", "narHash": "sha256-tZeFpETKQGbgnaSIO1AGWD27IyTcBm4D+A9d7ulQ4NM=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "25ae710ba3cd448c5d5678788d37f3d149378bc0", "rev": "511177ffe8226c78c9cf6a92a7b5f2df3684956b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -172,11 +172,11 @@
"systems": "systems" "systems": "systems"
}, },
"locked": { "locked": {
"lastModified": 1687171271, "lastModified": 1689068808,
"narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -287,11 +287,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1687805703, "lastModified": 1693791390,
"narHash": "sha256-/NsUv6EgH1FfgqyklpnHtUjfuGhMIMow0h1Iqqpf3QY=", "narHash": "sha256-FnT7/iDcGLWSmzwDfD7RQwr7z5+U2j7YOqhR3UM3zrg=",
"owner": "martinvonz", "owner": "martinvonz",
"repo": "jj", "repo": "jj",
"rev": "5e6dd17ed97a747c8615490f4fe3cdb8ed0ae238", "rev": "e3c85d6ecc20ee4240cdf3ed80107ce7dc268abe",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -384,11 +384,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1687103638, "lastModified": 1691683125,
"narHash": "sha256-dwy/TK6Db5W7ivcgmcxUykhFwodIg0jrRzOFt7H5NUc=", "narHash": "sha256-FMU62G57HDbJwU+9V3q7I0mBaQYTYQdtPNlJt2t5/A4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "91430887645a0953568da2f3e9a3a3bb0a0378ac", "rev": "4d2389b927696ef8da4ef76b03f2d306faf87929",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -441,11 +441,11 @@
}, },
"nixpkgs_7": { "nixpkgs_7": {
"locked": { "locked": {
"lastModified": 1689326639, "lastModified": 1693815579,
"narHash": "sha256-79zi0t83Dcc2dE0NuYZ+2hqtKXZN1yWVq5mtx8D2d7Y=", "narHash": "sha256-fPnIQlr0DoH9Z1C3v7IL3OpzMsvODC3k3oGu69r38+Y=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9fdfaeb7b96f05e869f838c73cde8d98c640c649", "rev": "1e409aeb5a9798a36e1cca227b7f8b8f3176e04d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -497,11 +497,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1687141659, "lastModified": 1691719735,
"narHash": "sha256-ckvEuxejYmFTyFF0u9CWV8h5u+ubuxA7vYrOw/GXRXg=", "narHash": "sha256-GhPn5EIhGt7aFwgC6RELZJC7mUIol9O0k7Dsf2Hu0AM=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "86302751ef371597d48951983e1a2f04fe78d4ff", "rev": "ac9d8b2e9acc153145e6fa3c78f9ba458ae517bf",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -519,11 +519,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1689302058, "lastModified": 1693793487,
"narHash": "sha256-yD74lcHTrw4niXcE9goJLbzsgyce48rQQoy5jK5ZK40=", "narHash": "sha256-MS6CDyAC0sJMTE/pRYlfrhBnhlAPvEo43ipwf5ZNzHg=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "7b8dbbf4c67ed05a9bf3d9e658c12d4108bc24c8", "rev": "f179280eed5eb93759c94bf3231fbbda28f894b7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -541,11 +541,11 @@
"nixpkgs": "nixpkgs_5" "nixpkgs": "nixpkgs_5"
}, },
"locked": { "locked": {
"lastModified": 1687444516, "lastModified": 1692759315,
"narHash": "sha256-2W3+qUZFGjbgIhCv6lXOulkwAWh6oqELThqRz8VkdjE=", "narHash": "sha256-nRA6Oad/CwUdMXlHpv1wW1IY5Pp100BJvIscd1AlYbI=",
"owner": "sile-typesetter", "owner": "sile-typesetter",
"repo": "sile", "repo": "sile",
"rev": "faf0b57f525cb8a6d9a4f2fa3b50888666dd7fd5", "rev": "fa84d15c902df4859caff8af8325097022b62f3e",
"type": "github" "type": "github"
}, },
"original": { "original": {