aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins/cmp.lua
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2022-10-14 23:43:14 +0200
committersrdusr <trevorgray@srdusr.com>2022-10-14 23:43:14 +0200
commit2d2c18e3b61a1883190fcd3c9dd9ab86002ddeab (patch)
tree614ed8e17635606d70f198c916591f5011d36155 /lua/plugins/cmp.lua
parent86628d459cabd0c29f0cdbb699e2e18807b958ed (diff)
downloaddotfiles-2d2c18e3b61a1883190fcd3c9dd9ab86002ddeab.tar.gz
dotfiles-2d2c18e3b61a1883190fcd3c9dd9ab86002ddeab.zip
Updated nvim-cmp & lsp: config/saga
Diffstat (limited to 'lua/plugins/cmp.lua')
-rw-r--r--lua/plugins/cmp.lua188
1 files changed, 105 insertions, 83 deletions
diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua
index 93bc5b2..fcec30f 100644
--- a/lua/plugins/cmp.lua
+++ b/lua/plugins/cmp.lua
@@ -1,58 +1,75 @@
+
+-- Setup nvim-cmp.
+vim.opt.completeopt = "menu,menuone,noselect"
+
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
-local lspkind = require("lspkind")
-cmp.setup({
- formatting = {
- format = lspkind.cmp_format({
- mode = "symbol", -- show only symbol annotations
- maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
- ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
-
- -- The function below will be called before any actual modifications from lspkind
- -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
- before = function(entry, vim_item)
- --...
- return vim_item
- end,
- }),
- },
-})
-require("luasnip/loaders/from_vscode").lazy_load()
+local opts = {
+ -- whether to highlight the currently hovered symbol
+ -- disable if your cpu usage is higher than you want it
+ -- or you just hate the highlight
+ -- default: true
+ highlight_hovered_item = true,
---   פּ ﯟ  some other good icons
-local kind_icons = {
- Text = "",
- Method = "",
- Function = "",
- Constructor = "⚙️",
- Field = "",
- Variable = "",
- Class = "ﴯ",
- Interface = "",
- Module = "",
- Property = "ﰠ",
- Unit = "",
- Value = "",
- Enum = "",
- Keyword = "",
- Snippet = "",
- Color = "",
- File = "",
- Reference = "",
- Folder = "",
- EnumMember = "",
- Constant = "",
- Struct = "",
- Event = "",
- Operator = "",
- TypeParameter = "",
+ -- whether to show outline guides
+ -- default: true
+ show_guides = true,
}
+require("symbols-outline").setup(opts)
--- find more here: https://www.nerdfonts.com/cheat-sheet
+local snippets_paths = function()
+ local plugins = { "friendly-snippets" }
+ local paths = {}
+ local path
+ local root_path = vim.env.HOME .. "/.vim/plugged/"
+ for _, plug in ipairs(plugins) do
+ path = root_path .. plug
+ if vim.fn.isdirectory(path) ~= 0 then
+ table.insert(paths, path)
+ end
+ end
+ return paths
+end
+
+require("luasnip.loaders.from_vscode").lazy_load({
+ paths = snippets_paths(),
+ include = nil, -- Load all languages
+ exclude = {},
+})
+
+local lspkind = require("lspkind")
+
+--local kind_icons = {
+-- Text = "",
+-- Method = "",
+-- Function = "",
+-- Constructor = "⚙️",
+-- Field = "",
+-- Variable = "",
+-- Class = "ﴯ",
+-- Interface = "",
+-- Module = "",
+-- Property = "ﰠ",
+-- Unit = "",
+-- Value = "",
+-- Enum = "",
+-- Keyword = "",
+-- Snippet = "",
+-- Color = "",
+-- File = "",
+-- Reference = "",
+-- Folder = "",
+-- EnumMember = "",
+-- Constant = "",
+-- Struct = "",
+-- Event = "",
+-- Operator = "",
+-- TypeParameter = "",
+--}
cmp.setup({
snippet = {
@@ -61,62 +78,65 @@ cmp.setup({
end,
},
mapping = cmp.mapping.preset.insert({
- ["<C-d>"] = cmp.mapping.scroll_docs(-4),
- ["<C-f>"] = cmp.mapping.scroll_docs(4),
- ["<C-Space>"] = cmp.mapping.complete(),
+-- ["<CR>"] = cmp.mapping.confirm({
+-- behavior = cmp.ConfirmBehavior.Replace,
+-- select = true,
+-- }),
+ ['<C-y>'] = cmp.mapping.confirm({ select = true }),
["<C-e>"] = cmp.mapping.close(),
- ["<CR>"] = cmp.mapping.confirm({
- behavior = cmp.ConfirmBehavior.Replace,
- select = true,
- }),
- }),
- sources = cmp.config.sources({
- { name = "path" },
- { name = "nvim_lsp", keyword_length = 3 },
- { name = "buffer", keyword_length = 3 },
- { name = "luasnip", keyword_length = 4 },
- { name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 },
- --{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this
- --{name = 'luasnip', keyword_length = 2},
+ ["<C-u>"] = cmp.mapping.scroll_docs(-4),
+ ["<C-d>"] = cmp.mapping.scroll_docs(4),
+ ["<C-Space>"] = cmp.mapping.complete(),
}),
+
formatting = {
- fields = { "kind", "abbr", "menu" },
+ fields = { "abbr", "kind", "menu" },
format = function(entry, vim_item)
-- Kind icons
- vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
+ --vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
+ vim_item.kind = lspkind.presets.default[vim_item.kind]
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
- nvim_lsp = "[LSP]",
- luasnip = "[Snippet]",
- buffer = "[Buffer]",
- path = "[Path]",
+ nvim_lsp = "LSP",
+ luasnip = "Snip",
+ buffer = "Buf",
+ path = "Path",
+ cmdline = "Cmd",
})[entry.source.name]
return vim_item
end,
},
- confirm_opts = {
+ sources = cmp.config.sources({
+ { name = "path" },
+ { name = "nvim_lsp", keyword_length = 3 },
+ { name = "luasnip", keyword_length = 4 },
+ { name = "buffer", keyword_length = 3 },
+ --{ name = 'treesitter' },
+ { name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 },
+ --{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this
+ --{name = 'luasnip', keyword_length = 2},
+ }),
+ confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
- documentation = {
- border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
- },
- },
- experimental = {
- ghost_text = true,
- native_menu = false,
- --view = {
- -- entries = "native"
+ completion = cmp.config.window.bordered(),
+ documentation = cmp.config.window.bordered(),
+ --documentation = {
+ -- border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
--},
},
+-- experimental = {
+-- ghost_text = true,
+-- native_menu = true,
+-- --native_menu = false,
+-- --view = {
+-- -- entries = "native"
+-- --},
+-- },
})
---vim.cmd([[
--- set completeopt=menuone,noinsert,noselect
--- highlight! default link CmpItemKind CmpItemMenuDefault
---]])
-
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
@@ -132,3 +152,5 @@ cmp.setup.cmdline(":", {
{ name = "cmdline" },
}),
})
+
+