forked from ixahmedxi/trashvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: changes cmp & lsp_signature behaviours
This commit brings the following changes: - Removes the enter to select first item in cmp as that sometimes you don't mean to press the completion and just want to make a new line. - Removes the automatic lsp_signature float window as that sometimes it's a bit annoying, coming up everywhere. It can be manually toggled using ctrl + k. - Formats all files using stylua.
- Loading branch information
Showing
6 changed files
with
153 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,114 @@ | ||
import({ "cmp", "luasnip", "lspkind", "luasnip/loaders/from_vscode" }, function(modules) | ||
modules["luasnip/loaders/from_vscode"].lazy_load() | ||
modules["luasnip/loaders/from_vscode"].lazy_load() | ||
|
||
local check_backspace = function() | ||
local col = vim.fn.col(".") - 1 | ||
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") | ||
end | ||
local check_backspace = function() | ||
local col = vim.fn.col(".") - 1 | ||
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") | ||
end | ||
|
||
modules.cmp.setup({ | ||
snippet = { | ||
expand = function(args) | ||
modules.luasnip.lsp_expand(args.body) | ||
end, | ||
}, | ||
mapping = { | ||
["<C-k>"] = modules.cmp.mapping.select_prev_item(), | ||
["<C-j>"] = modules.cmp.mapping.select_next_item(), | ||
["<C-b>"] = modules.cmp.mapping(modules.cmp.mapping.scroll_docs(-1), { "i", "c" }), | ||
["<C-f>"] = modules.cmp.mapping(modules.cmp.mapping.scroll_docs(1), { "i", "c" }), | ||
["<C-Space>"] = modules.cmp.mapping(modules.cmp.mapping.complete(), { "i", "c" }), | ||
["<C-y>"] = modules.cmp.config.disable, | ||
["<C-e>"] = modules.cmp.mapping({ | ||
i = modules.cmp.mapping.abort(), | ||
c = modules.cmp.mapping.close(), | ||
}), | ||
["<CR>"] = modules.cmp.mapping.confirm({ select = true }), | ||
["<Tab>"] = modules.cmp.mapping(function(fallback) | ||
if modules.cmp.visible() then | ||
modules.cmp.select_next_item() | ||
elseif modules.luasnip.expandable() then | ||
modules.luasnip.expand() | ||
elseif modules.luasnip.expand_or_jumpable() then | ||
modules.luasnip.expand_or_jump() | ||
elseif check_backspace() then | ||
fallback() | ||
else | ||
fallback() | ||
end | ||
end, { | ||
"i", | ||
"s", | ||
}), | ||
["<S-Tab>"] = modules.cmp.mapping(function(fallback) | ||
if modules.cmp.visible() then | ||
modules.cmp.select_prev_item() | ||
elseif modules.luasnip.jumpable(-1) then | ||
modules.luasnip.jump(-1) | ||
else | ||
fallback() | ||
end | ||
end, { | ||
"i", | ||
"s", | ||
}), | ||
}, | ||
formatting = { | ||
fields = { "abbr", "kind", "menu" }, | ||
format = modules.lspkind.cmp_format({ | ||
mode = "symbol_text", | ||
symbol_map = { | ||
Copilot = "", | ||
}, | ||
before = function(entry, vim_item) | ||
vim_item.menu = ({ | ||
nvim_lsp = "[LSP]", | ||
luasnip = "[Snippet]", | ||
buffer = "[Buffer]", | ||
path = "[Path]", | ||
})[entry.source.name] | ||
return vim_item | ||
end, | ||
}), | ||
}, | ||
sources = { | ||
{ name = "nvim_lsp", group_index = 1, keyword_length = 4 }, | ||
{ name = "copilot", group_index = 1 }, | ||
{ name = "luasnip", group_index = 2 }, | ||
{ name = "buffer", group_index = 2 }, | ||
{ name = "path", group_index = 2 }, | ||
}, | ||
confirm_opts = { | ||
behavior = modules.cmp.ConfirmBehavior.Replace, | ||
select = false, | ||
}, | ||
window = { | ||
completion = modules.cmp.config.window.bordered(), | ||
documentation = modules.cmp.config.window.bordered(), | ||
}, | ||
experimental = { | ||
ghost_text = false, | ||
native_menu = false, | ||
}, | ||
performance = { | ||
trigger_debounce_time = 500, | ||
throttle = 550, | ||
fetching_timeout = 80, | ||
}, | ||
}) | ||
modules.cmp.setup({ | ||
snippet = { | ||
expand = function(args) | ||
modules.luasnip.lsp_expand(args.body) | ||
end, | ||
}, | ||
mapping = { | ||
["<C-k>"] = modules.cmp.mapping.select_prev_item(), | ||
["<C-j>"] = modules.cmp.mapping.select_next_item(), | ||
["<C-b>"] = modules.cmp.mapping(modules.cmp.mapping.scroll_docs(-1), { "i", "c" }), | ||
["<C-f>"] = modules.cmp.mapping(modules.cmp.mapping.scroll_docs(1), { "i", "c" }), | ||
["<C-Space>"] = modules.cmp.mapping(modules.cmp.mapping.complete(), { "i", "c" }), | ||
["<C-y>"] = modules.cmp.config.disable, | ||
["<C-e>"] = modules.cmp.mapping({ | ||
i = modules.cmp.mapping.abort(), | ||
c = modules.cmp.mapping.close(), | ||
}), | ||
["<Tab>"] = modules.cmp.mapping(function(fallback) | ||
if modules.cmp.visible() then | ||
modules.cmp.select_next_item() | ||
elseif modules.luasnip.expandable() then | ||
modules.luasnip.expand() | ||
elseif modules.luasnip.expand_or_jumpable() then | ||
modules.luasnip.expand_or_jump() | ||
elseif check_backspace() then | ||
fallback() | ||
else | ||
fallback() | ||
end | ||
end, { | ||
"i", | ||
"s", | ||
}), | ||
["<S-Tab>"] = modules.cmp.mapping(function(fallback) | ||
if modules.cmp.visible() then | ||
modules.cmp.select_prev_item() | ||
elseif modules.luasnip.jumpable(-1) then | ||
modules.luasnip.jump(-1) | ||
else | ||
fallback() | ||
end | ||
end, { | ||
"i", | ||
"s", | ||
}), | ||
}, | ||
formatting = { | ||
fields = { "abbr", "kind", "menu" }, | ||
format = modules.lspkind.cmp_format({ | ||
mode = "symbol_text", | ||
symbol_map = { | ||
Copilot = "", | ||
}, | ||
before = function(entry, vim_item) | ||
vim_item.menu = ({ | ||
nvim_lsp = "[LSP]", | ||
luasnip = "[Snippet]", | ||
buffer = "[Buffer]", | ||
path = "[Path]", | ||
})[entry.source.name] | ||
return vim_item | ||
end, | ||
}), | ||
}, | ||
sources = { | ||
{ name = "nvim_lsp", group_index = 1, keyword_length = 4 }, | ||
{ name = "copilot", group_index = 1 }, | ||
{ name = "luasnip", group_index = 2 }, | ||
{ name = "buffer", group_index = 2 }, | ||
{ name = "path", group_index = 2 }, | ||
}, | ||
confirm_opts = { | ||
behavior = modules.cmp.ConfirmBehavior.Replace, | ||
select = false, | ||
}, | ||
window = { | ||
completion = modules.cmp.config.window.bordered(), | ||
documentation = modules.cmp.config.window.bordered(), | ||
}, | ||
experimental = { | ||
ghost_text = false, | ||
native_menu = false, | ||
}, | ||
performance = { | ||
trigger_debounce_time = 500, | ||
throttle = 550, | ||
fetching_timeout = 80, | ||
}, | ||
}) | ||
|
||
modules.cmp.setup.cmdline({ "/", "?" }, { | ||
mapping = modules.cmp.mapping.preset.cmdline(), | ||
sources = { | ||
{ name = "buffer" }, | ||
}, | ||
}) | ||
modules.cmp.setup.cmdline({ "/", "?" }, { | ||
mapping = modules.cmp.mapping.preset.cmdline(), | ||
sources = { | ||
{ name = "buffer" }, | ||
}, | ||
}) | ||
|
||
modules.cmp.setup.cmdline(":", { | ||
mapping = modules.cmp.mapping.preset.cmdline(), | ||
sources = modules.cmp.config.sources({ | ||
{ name = "path" }, | ||
}, { | ||
{ name = "cmdline" }, | ||
}), | ||
}) | ||
modules.cmp.setup.cmdline(":", { | ||
mapping = modules.cmp.mapping.preset.cmdline(), | ||
sources = modules.cmp.config.sources({ | ||
{ name = "path" }, | ||
}, { | ||
{ name = "cmdline" }, | ||
}), | ||
}) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import("catppuccin", function(catppuccin) | ||
catppuccin.setup({ | ||
flavour = "mocha", -- latte, frappe, macchiato, mocha | ||
term_colors = true, | ||
transparent_background = false, | ||
no_italic = false, | ||
no_bold = false, | ||
styles = { | ||
comments = {}, | ||
conditionals = {}, | ||
loops = {}, | ||
functions = {}, | ||
keywords = {}, | ||
strings = {}, | ||
variables = {}, | ||
numbers = {}, | ||
booleans = {}, | ||
properties = {}, | ||
types = {}, | ||
}, | ||
color_overrides = { | ||
mocha = { | ||
base = "#000000", | ||
}, | ||
}, | ||
highlight_overrides = { | ||
mocha = function(C) | ||
return { | ||
TabLineSel = { bg = C.pink }, | ||
NvimTreeNormal = { bg = C.none }, | ||
CmpBorder = { fg = C.surface2 }, | ||
Pmenu = { bg = C.none }, | ||
NormalFloat = { bg = C.none }, | ||
TelescopeBorder = { link = "FloatBorder" }, | ||
} | ||
end, | ||
}, | ||
}) | ||
vim.cmd.colorscheme("catppuccin") | ||
catppuccin.setup({ | ||
flavour = "mocha", -- latte, frappe, macchiato, mocha | ||
term_colors = true, | ||
transparent_background = false, | ||
no_italic = false, | ||
no_bold = false, | ||
styles = { | ||
comments = {}, | ||
conditionals = {}, | ||
loops = {}, | ||
functions = {}, | ||
keywords = {}, | ||
strings = {}, | ||
variables = {}, | ||
numbers = {}, | ||
booleans = {}, | ||
properties = {}, | ||
types = {}, | ||
}, | ||
color_overrides = { | ||
mocha = { | ||
base = "#000000", | ||
}, | ||
}, | ||
highlight_overrides = { | ||
mocha = function(C) | ||
return { | ||
TabLineSel = { bg = C.pink }, | ||
NvimTreeNormal = { bg = C.none }, | ||
CmpBorder = { fg = C.surface2 }, | ||
Pmenu = { bg = C.none }, | ||
NormalFloat = { bg = C.none }, | ||
TelescopeBorder = { link = "FloatBorder" }, | ||
} | ||
end, | ||
}, | ||
}) | ||
vim.cmd.colorscheme("catppuccin") | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import("git-conflict", function (gitConflict) | ||
gitConflict.setup() | ||
import("git-conflict", function(gitConflict) | ||
gitConflict.setup() | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import("tmux", function (tmux) | ||
tmux.setup() | ||
import("tmux", function(tmux) | ||
tmux.setup() | ||
end) |