Skip to content

Commit 7351650

Browse files
committed
Finished?
1 parent f4c5e0e commit 7351650

File tree

4 files changed

+215
-1
lines changed

4 files changed

+215
-1
lines changed

lua/lipe/plugins/lsp.bak/cmp.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ return {
2020
"saadparwaiz1/cmp_luasnip", -- Snippet completion
2121
"hrsh7th/cmp-buffer", -- Buffer completion
2222
"hrsh7th/cmp-path", -- Path completion
23-
"windwp/nvim-autopairs", -- Autopair
2423
"hrsh7th/cmp-nvim-lsp", -- LSP completion
2524
"onsails/lspkind.nvim", -- LSP completion formatter
25+
"windwp/nvim-autopairs", -- Autopair
2626
},
2727
config = function()
2828
local cmp = require("cmp")

lua/lipe/plugins/lsp/cmp.lua

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
return {
2+
{
3+
"hrsh7th/nvim-cmp",
4+
-- event = "InsertEnter", -- lazy-load this if want a faster startup time
5+
dependencies = {
6+
"L3MON4D3/LuaSnip", -- Snippet engine
7+
"saadparwaiz1/cmp_luasnip", -- Snippet completion
8+
"hrsh7th/cmp-buffer", -- Buffer completion
9+
"hrsh7th/cmp-path", -- Path completion
10+
"hrsh7th/cmp-nvim-lsp", -- LSP completion
11+
"onsails/lspkind.nvim", -- LSP completion formatter
12+
"windwp/nvim-autopairs", -- Autopair
13+
},
14+
config = function()
15+
local cmp = require("cmp")
16+
local luasnip = require("luasnip")
17+
18+
-- Utility function to check backspace in "magic tab snippet"
19+
local check_backspace = function()
20+
local col = vim.fn.col "." - 1
21+
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
22+
end
23+
24+
cmp.setup {
25+
snippet = {
26+
expand = function(args)
27+
luasnip.lsp_expand(args.body)
28+
end,
29+
},
30+
mapping = {
31+
["<C-k>"] = cmp.mapping.select_prev_item(),
32+
["<C-j>"] = cmp.mapping.select_next_item(),
33+
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
34+
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
35+
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
36+
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
37+
["<C-e>"] = cmp.mapping {
38+
i = cmp.mapping.abort(),
39+
c = cmp.mapping.close(),
40+
},
41+
-- Accept currently selected item. If none selected, `select` first item.
42+
-- Set `select` to `false` to only confirm explicitly selected items.
43+
["<CR>"] = cmp.mapping.confirm { select = true },
44+
["<Tab>"] = cmp.mapping(function(fallback)
45+
if cmp.visible() then
46+
cmp.select_next_item()
47+
elseif luasnip.expandable() then
48+
luasnip.expand()
49+
elseif luasnip.expand_or_jumpable() then
50+
luasnip.expand_or_jump()
51+
elseif check_backspace() then
52+
fallback()
53+
else
54+
fallback()
55+
end
56+
end, {
57+
"i",
58+
"s",
59+
}),
60+
["<S-Tab>"] = cmp.mapping(function(fallback)
61+
if cmp.visible() then
62+
cmp.select_prev_item()
63+
elseif luasnip.jumpable(-1) then
64+
luasnip.jump(-1)
65+
else
66+
fallback()
67+
end
68+
end, {
69+
"i",
70+
"s",
71+
}),
72+
},
73+
formatting = {
74+
fields = { "kind", "abbr", "menu" },
75+
format = function(entry, vim_item)
76+
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
77+
local strings = vim.split(kind.kind, "%s", { trimempty = true })
78+
kind.kind = " " .. (strings[1] or "") .. " "
79+
kind.menu = " (" .. (strings[2] or "") .. ")"
80+
81+
return kind
82+
end,
83+
},
84+
sources = {
85+
{ name = "nvim_lsp" },
86+
{ name = "luasnip" },
87+
{ name = "buffer" },
88+
{ name = "path" },
89+
},
90+
confirm_opts = {
91+
behavior = cmp.ConfirmBehavior.Replace,
92+
select = false,
93+
},
94+
window = {
95+
completion = cmp.config.window.bordered({
96+
border = "single",
97+
}),
98+
documentation = cmp.config.window.bordered({
99+
border = { "", "", "", "", "", "", "", "" },
100+
}),
101+
},
102+
experimental = {
103+
ghost_text = false,
104+
native_menu = false,
105+
},
106+
}
107+
108+
-- Link autocompt with cmp
109+
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
110+
cmp.event:on(
111+
'confirm_done',
112+
cmp_autopairs.on_confirm_done()
113+
)
114+
115+
-- -- gray
116+
-- vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { bg = 'NONE', strikethrough = true, fg = '#808080' })
117+
-- -- blue
118+
-- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { bg = 'NONE', fg = '#569CD6' })
119+
-- vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { link = 'CmpIntemAbbrMatch' })
120+
-- -- light blue
121+
-- vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { bg = 'NONE', fg = '#9CDCFE' })
122+
-- vim.api.nvim_set_hl(0, 'CmpItemKindVariable', { bg = 'NONE', fg = '#FF00FF' })
123+
-- vim.api.nvim_set_hl(0, 'CmpItemKindInterface', { link = 'CmpItemKindVariable' })
124+
-- vim.api.nvim_set_hl(0, 'CmpItemKindText', { link = 'CmpItemKindVariable' })
125+
-- -- pink
126+
-- vim.api.nvim_set_hl(0, 'CmpItemKindFunction', { bg = 'NONE', fg = '#C586C0' })
127+
-- vim.api.nvim_set_hl(0, 'CmpItemKindMethod', { link = 'CmpItemKindFunction' })
128+
-- -- front
129+
-- vim.api.nvim_set_hl(0, 'CmpItemKindKeyword', { bg = 'NONE', fg = '#D4D4D4' })
130+
-- vim.api.nvim_set_hl(0, 'CmpItemKindProperty', { link = 'CmpItemKindKeyword' })
131+
-- vim.api.nvim_set_hl(0, 'CmpItemKindUnit', { link = 'CmpItemKindKeyword' })
132+
end,
133+
},
134+
135+
}

lua/lipe/plugins/lsp/snippets.lua

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
return {
2+
{
3+
"rafamadriz/friendly-snippets",
4+
lazy = true, -- luasnip will load friendly-snippets
5+
},
6+
{
7+
"L3MON4D3/LuaSnip",
8+
version = "v2.*",
9+
lazy = true, -- nvim-cmp will load luasnip
10+
dependencies = {
11+
"rafamadriz/friendly-snippets",
12+
},
13+
config = function()
14+
require("luasnip/loaders/from_vscode").lazy_load()
15+
end,
16+
build = "make install_jsregexp", -- Optional
17+
},
18+
}

lua/lipe/plugins/lsp/trouble.lua

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
return {
2+
"folke/trouble.nvim",
3+
cmd = "TroubleToggle",
4+
dependencies = { "nvim-tree/nvim-web-devicons" },
5+
opts = {
6+
position = "bottom", -- position of the list can be: bottom, top, left, right
7+
height = 10, -- height of the trouble list when position is top or bottom
8+
width = 50, -- width of the list when position is left or right
9+
icons = true, -- use devicons for filenames
10+
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
11+
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
12+
fold_open = "", -- icon used for open folds
13+
fold_closed = "", -- icon used for closed folds
14+
group = true, -- group results by file
15+
padding = true, -- add an extra new line on top of the list
16+
cycle_results = true, -- cycle item list when reaching beginning or end of list
17+
action_keys = { -- key mappings for actions in the trouble list
18+
19+
-- map to {} to remove a mapping, for example:
20+
-- close = {},
21+
close = "q", -- close the list
22+
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
23+
refresh = "r", -- manually refresh
24+
jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds
25+
open_split = { "<c-x>" }, -- open buffer in new split
26+
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
27+
open_tab = { "<c-t>" }, -- open buffer in new tab
28+
jump_close = { "o" }, -- jump to the diagnostic and close the list
29+
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
30+
switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR
31+
toggle_preview = "P", -- toggle auto_preview
32+
hover = "K", -- opens a small popup with the full multiline message
33+
preview = "p", -- preview the diagnostic location
34+
open_code_href = "c", -- if present, open a URI with more information about the diagnostic error
35+
close_folds = { "zM", "zm" }, -- close all folds
36+
open_folds = { "zR", "zr" }, -- open all folds
37+
toggle_fold = { "zA", "za" }, -- toggle fold of current file
38+
previous = "k", -- previous item
39+
next = "j", -- next item
40+
help = "?" -- help menu
41+
},
42+
multiline = true, -- render multi-line messages
43+
indent_lines = true, -- add an indent guide below the fold icons
44+
win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|.
45+
auto_open = false, -- automatically open the list when you have diagnostics
46+
auto_close = false, -- automatically close the list when you have no diagnostics
47+
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
48+
auto_fold = false, -- automatically fold a file trouble list at creation
49+
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
50+
include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results
51+
signs = {
52+
-- icons / text used for a diagnostic
53+
error = ICONS.diagnostics.Error,
54+
warning = ICONS.diagnostics.Warning,
55+
hint = ICONS.diagnostics.Hint,
56+
information = ICONS.diagnostics.Information,
57+
other = ICONS.diagnostics.Information,
58+
},
59+
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
60+
},
61+
}

0 commit comments

Comments
 (0)