diff --git a/nix/base-system/flake.nix b/nix/base-system/flake.nix index 13d1db3..3f85155 100644 --- a/nix/base-system/flake.nix +++ b/nix/base-system/flake.nix @@ -84,7 +84,13 @@ EOF"; packer-nvim vim-lsp vim-vsnip - coq_nvim + nvim-cmp + cmp-nvim-lua + cmp-nvim-lsp + cmp-vsnip + cmp-buffer + cmp-path + cmp-nvim-lsp-signature-help vimspector vimagit hoon-vim diff --git a/nix/base-system/init.lua b/nix/base-system/init.lua index fd8b462..2312353 100644 --- a/nix/base-system/init.lua +++ b/nix/base-system/init.lua @@ -1,7 +1,7 @@ -- theming -- Default options -vim.opt.termguicolors = true -vim.cmd.colorscheme 'duskfox' +--vim.opt.termguicolors = true +--vim.cmd.colorscheme 'duskfox' -- turn on relative line numbers vim.opt.relativenumber = true @@ -52,7 +52,61 @@ vim.cmd([[ 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 +-- 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( 'force', @@ -61,6 +115,8 @@ local caps = vim.tbl_deep_extend( ); local lspconfig = require("lspconfig") +local capabilities = require('cmp_nvim_lsp').default_capabilities() + -- Nix language server support lspconfig.nil_ls.setup{} @@ -105,7 +161,9 @@ lspconfig.java_language_server.setup{} lspconfig.tsserver.setup{} -- Rust language server support -lspconfig.rust_analyzer.setup{} +lspconfig.rust_analyzer.setup{ + capabilities = capabilities +} -- lua language server setup. lspconfig.lua_ls.setup{ @@ -196,8 +254,6 @@ vim.cmd([[ let g:coq_settings = { 'auto_start': 'shut-up', 'display.icons.mode': "none" } ]]) -require("coq") - --Set completeopt to have a better completion experience -- :help completeopt -- menuone: popup even when there's only one match diff --git a/nix/darwin/flake.lock b/nix/darwin/flake.lock index 1a92986..bed427b 100644 --- a/nix/darwin/flake.lock +++ b/nix/darwin/flake.lock @@ -7,11 +7,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1684153753, - "narHash": "sha256-PVbWt3qrjYAK+T5KplFcO+h7aZWfEj1UtyoKlvcDxh0=", + "lastModified": 1690228878, + "narHash": "sha256-9Xe7JV0krp4RJC9W9W9WutZVlw6BlHTFMiUP/k48LQY=", "owner": "ryantm", "repo": "agenix", - "rev": "db5637d10f797bb251b94ef9040b237f4702cde3", + "rev": "d8c973fd228949736dedf61b7f8cc1ece3236792", "type": "github" }, "original": { @@ -34,12 +34,12 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-zUkrSqkKiphniy9Dv8MJpsJKt4HMEoPIpoW6SQyzeOQ=", - "path": "/nix/store/f9c9966csi39qz43kg1j16w3phnkdj4d-source/nix/base-system", + "narHash": "sha256-uA4sSuHPv0RuNibC98a+mBh/GnMS1vXrwFIE1XP8AIs=", + "path": "/nix/store/pzjnc2vf0y96kai86a1m9m54m33lxwpq-source/nix/base-system", "type": "path" }, "original": { - "path": "/nix/store/f9c9966csi39qz43kg1j16w3phnkdj4d-source/nix/base-system", + "path": "/nix/store/pzjnc2vf0y96kai86a1m9m54m33lxwpq-source/nix/base-system", "type": "path" } }, @@ -71,11 +71,11 @@ "nixpkgs": "nixpkgs_6" }, "locked": { - "lastModified": 1687691275, - "narHash": "sha256-VVywT8ubStvDPF5TscDBokT3T0l3zsOzCW056noh5zc=", + "lastModified": 1692248770, + "narHash": "sha256-tZeFpETKQGbgnaSIO1AGWD27IyTcBm4D+A9d7ulQ4NM=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "25ae710ba3cd448c5d5678788d37f3d149378bc0", + "rev": "511177ffe8226c78c9cf6a92a7b5f2df3684956b", "type": "github" }, "original": { @@ -172,11 +172,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1687171271, - "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "owner": "numtide", "repo": "flake-utils", - "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { @@ -287,11 +287,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1687805703, - "narHash": "sha256-/NsUv6EgH1FfgqyklpnHtUjfuGhMIMow0h1Iqqpf3QY=", + "lastModified": 1693791390, + "narHash": "sha256-FnT7/iDcGLWSmzwDfD7RQwr7z5+U2j7YOqhR3UM3zrg=", "owner": "martinvonz", "repo": "jj", - "rev": "5e6dd17ed97a747c8615490f4fe3cdb8ed0ae238", + "rev": "e3c85d6ecc20ee4240cdf3ed80107ce7dc268abe", "type": "github" }, "original": { @@ -384,11 +384,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1687103638, - "narHash": "sha256-dwy/TK6Db5W7ivcgmcxUykhFwodIg0jrRzOFt7H5NUc=", + "lastModified": 1691683125, + "narHash": "sha256-FMU62G57HDbJwU+9V3q7I0mBaQYTYQdtPNlJt2t5/A4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "91430887645a0953568da2f3e9a3a3bb0a0378ac", + "rev": "4d2389b927696ef8da4ef76b03f2d306faf87929", "type": "github" }, "original": { @@ -441,11 +441,11 @@ }, "nixpkgs_7": { "locked": { - "lastModified": 1689326639, - "narHash": "sha256-79zi0t83Dcc2dE0NuYZ+2hqtKXZN1yWVq5mtx8D2d7Y=", + "lastModified": 1693815579, + "narHash": "sha256-fPnIQlr0DoH9Z1C3v7IL3OpzMsvODC3k3oGu69r38+Y=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9fdfaeb7b96f05e869f838c73cde8d98c640c649", + "rev": "1e409aeb5a9798a36e1cca227b7f8b8f3176e04d", "type": "github" }, "original": { @@ -497,11 +497,11 @@ ] }, "locked": { - "lastModified": 1687141659, - "narHash": "sha256-ckvEuxejYmFTyFF0u9CWV8h5u+ubuxA7vYrOw/GXRXg=", + "lastModified": 1691719735, + "narHash": "sha256-GhPn5EIhGt7aFwgC6RELZJC7mUIol9O0k7Dsf2Hu0AM=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "86302751ef371597d48951983e1a2f04fe78d4ff", + "rev": "ac9d8b2e9acc153145e6fa3c78f9ba458ae517bf", "type": "github" }, "original": { @@ -519,11 +519,11 @@ ] }, "locked": { - "lastModified": 1689302058, - "narHash": "sha256-yD74lcHTrw4niXcE9goJLbzsgyce48rQQoy5jK5ZK40=", + "lastModified": 1693793487, + "narHash": "sha256-MS6CDyAC0sJMTE/pRYlfrhBnhlAPvEo43ipwf5ZNzHg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "7b8dbbf4c67ed05a9bf3d9e658c12d4108bc24c8", + "rev": "f179280eed5eb93759c94bf3231fbbda28f894b7", "type": "github" }, "original": { @@ -541,11 +541,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1687444516, - "narHash": "sha256-2W3+qUZFGjbgIhCv6lXOulkwAWh6oqELThqRz8VkdjE=", + "lastModified": 1692759315, + "narHash": "sha256-nRA6Oad/CwUdMXlHpv1wW1IY5Pp100BJvIscd1AlYbI=", "owner": "sile-typesetter", "repo": "sile", - "rev": "faf0b57f525cb8a6d9a4f2fa3b50888666dd7fd5", + "rev": "fa84d15c902df4859caff8af8325097022b62f3e", "type": "github" }, "original": {