summaryrefslogtreecommitdiffstatshomepage
path: root/nvim/.config
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/.config')
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins.lua13
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua120
2 files changed, 69 insertions, 64 deletions
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins.lua b/nvim/.config/nvim/lua/tobyvin/plugins.lua
index dca8de3..4f0bddb 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins.lua
@@ -115,19 +115,18 @@ local plugins = function(use)
use({
"hrsh7th/nvim-cmp",
requires = {
+ "hrsh7th/cmp-buffer",
+ "hrsh7th/cmp-path",
"hrsh7th/cmp-nvim-lsp",
+ "hrsh7th/cmp-nvim-lsp-document-symbol",
+ "hrsh7th/cmp-nvim-lsp-signature-help",
"hrsh7th/cmp-nvim-lua",
- "hrsh7th/cmp-path",
- "hrsh7th/cmp-buffer",
"hrsh7th/cmp-cmdline",
- "dmitmel/cmp-cmdline-history",
- "hrsh7th/cmp-calc",
- "ray-x/lsp_signature.nvim",
- "hrsh7th/cmp-nvim-lsp-signature-help",
- "rcarriga/cmp-dap",
"petertriho/cmp-git",
"Dosx001/cmp-commit",
"davidsierradz/cmp-conventionalcommits",
+ "rcarriga/cmp-dap",
+ "ray-x/lsp_signature.nvim",
"saadparwaiz1/cmp_luasnip",
"saecki/crates.nvim",
"kdheepak/cmp-latex-symbols",
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
index c296c0b..80d885c 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
@@ -5,26 +5,27 @@ if not status_ok then
end
local lsp = require("tobyvin.lsp")
+local luasnip = require("luasnip")
+local default = require("cmp.config.default")()
+local context = require("cmp.config.context")
+local cmp_dap = require("cmp_dap")
+local cmp_nvim_lsp = require("cmp_nvim_lsp")
+
+local in_comment = function()
+ return vim.api.nvim_get_mode().mode ~= "c"
+ and context.in_treesitter_capture("comment")
+ and context.in_syntax_group("Comment")
+end
local enabled = function()
- local ctx = require("cmp.config.context")
- local enabled = require("cmp.config.default")().enabled() or require("cmp_dap").is_dap_buffer()
- if vim.api.nvim_get_mode().mode ~= "c" then
- enabled = enabled and not ctx.in_treesitter_capture("comment")
- enabled = enabled and not ctx.in_syntax_group("Comment")
- end
- return enabled
+ return (default.enabled() or cmp_dap.is_dap_buffer()) and not in_comment()
end
local expand_snip = function(args)
- require("luasnip").lsp_expand(args.body)
+ luasnip.lsp_expand(args.body)
end
-lsp.default_config = vim.tbl_extend("force", lsp.default_config, {
- capabilities = require("cmp_nvim_lsp").default_capabilities(),
-})
-
-cmp.setup({
+cmp.setup.global({
enabled = enabled,
window = {
completion = cmp.config.window.bordered({ border = "single" }),
@@ -33,83 +34,88 @@ cmp.setup({
snippet = {
expand = expand_snip,
},
- mapping = cmp.mapping.preset.cmdline({
- ["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }),
- ["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
- ["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }),
- ["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
- ["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "s" }),
- ["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "s" }),
- ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "s" }),
- ["<C-e>"] = cmp.mapping(cmp.mapping.close(), { "i", "s" }),
- ["<CR>"] = cmp.mapping(
- cmp.mapping.confirm({
- behavior = cmp.ConfirmBehavior.Insert,
- -- select = true,
- }),
- { "i", "s" }
- ),
+ mapping = cmp.mapping.preset.insert({
+ ["<Tab>"] = { i = cmp.mapping.select_next_item() },
+ ["<S-Tab>"] = { i = cmp.mapping.select_prev_item() },
+ ["<C-d>"] = { i = cmp.mapping.scroll_docs(4) },
+ ["<C-u>"] = { i = cmp.mapping.scroll_docs(-4) },
+ ["<C-Space>"] = { i = cmp.mapping.complete() },
+ ["<CR>"] = { i = cmp.mapping.confirm() },
}),
- ghost_text = true,
sources = {
- { name = "nvim_lsp", group_index = 1 },
- { name = "nvim_lua", group_index = 1 },
- { name = "path", group_index = 1 },
- { name = "luasnip", group_index = 1 },
- { name = "dap", group_index = 1 },
- { name = "buffer", keyword_length = 3, group_index = 2 },
+ { name = "nvim_lsp" },
+ { name = "nvim_lsp_signature_help" },
+ { name = "luasnip" },
+ { name = "path" },
+ { name = "dap" },
},
})
-cmp.setup.filetype({ "tex", "bib" }, {
+local cmd_mapping = cmp.mapping.preset.cmdline({
+ ["<C-Space>"] = { c = cmp.mapping.complete() },
+ ["<C-e>"] = { c = cmp.mapping.abort() },
+})
+
+cmp.setup.cmdline(":", {
+ mapping = cmd_mapping,
sources = {
- { name = "latex_symbols" },
+ { name = "cmdline", max_item_count = 10 },
},
})
-cmp.setup.filetype("gitcommit", {
+cmp.setup.cmdline({ "/", "?", "@" }, {
+ mapping = cmd_mapping,
sources = {
- { name = "git" },
- { name = "commit" },
- { name = "conventionalcommits" },
+ { name = "nvim_lsp_document_symbol", max_item_count = 10, group_index = 1 },
+ { name = "buffer", keyword_length = 3, max_item_count = 10, group_index = 2 },
},
})
-cmp.setup.filetype("json", {
+cmp.setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, {
sources = {
- { name = "npm" },
+ { name = "dap" },
},
})
-cmp.setup.filetype("toml", {
+cmp.setup.filetype({
+ "tex",
+ "bib",
+ "sh",
+ "zsh",
+ "xml",
+ "markdown",
+}, {
sources = {
- { name = "crates" },
+ { name = "buffer", keyword_length = 3, group_index = 2 },
},
})
-cmp.setup.cmdline(":", {
+cmp.setup.filetype({ "tex", "bib" }, {
sources = {
- { name = "cmdline_history", max_item_count = 10 },
- { name = "cmdline", max_item_count = 10 },
+ { name = "latex_symbols" },
},
})
-cmp.setup.cmdline("/", {
+cmp.setup.filetype("gitcommit", {
sources = {
- { name = "buffer", max_item_count = 10 },
- { name = "cmdline_history", max_item_count = 10 },
+ { name = "git" },
+ { name = "commit" },
+ { name = "conventionalcommits" },
},
})
-cmp.setup.cmdline("?", {
+cmp.setup.filetype("json", {
sources = {
- { name = "buffer", max_item_count = 10 },
- { name = "cmdline_history", max_item_count = 10 },
+ { name = "npm" },
},
})
-cmp.setup.cmdline("@", {
+cmp.setup.filetype("toml", {
sources = {
- { name = "cmdline_history", max_item_count = 10 },
+ { name = "crates" },
},
})
+
+lsp.default_config = vim.tbl_extend("force", lsp.default_config, {
+ capabilities = cmp_nvim_lsp.default_capabilities(),
+})