feat: Updates plugins for nvim

This commit is contained in:
2024-11-16 11:38:43 -05:00
parent 3b75e6e918
commit f6f45a8c58
7 changed files with 143 additions and 131 deletions

View File

@@ -12,10 +12,10 @@ return {
"f3fora/cmp-spell",
"hrsh7th/cmp-calc",
"hrsh7th/cmp-emoji",
--"L3MON4D3/LuaSnip",
"L3MON4D3/LuaSnip",
-- Adds a number of user-friendly snippets
'rafamadriz/friendly-snippets',
"onsails/lspkind.nvim", -- vs-code like pictograms
},
event = { 'BufReadPre', 'BufNewFile' },
config = function()
@@ -24,24 +24,13 @@ return {
local lspkind = require("lspkind")
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
--local luasnip = require('luasnip')
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(
col, col):match("%s") == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true),
mode, true)
end
local luasnip = require('luasnip')
require('lspconfig').sourcekit.setup {
capabilities = capabilities
}
require("luasnip.loaders.from_vscode").lazy_load()
lspkind.init({
symbol_map = {
@@ -74,84 +63,55 @@ return {
}
})
-- Configure nvim-cmp.
--require('luasnip.loaders.from_vscode').lazy_load()
--luasnip.config.setup {}
cmp.setup({
formatting = {
format = lspkind.cmp_format {
with_text = false,
maxwidth = 50,
menu = {
buffer = "BUF",
nvim_lsp = "LSP",
path = "PATH",
vsnip = "SNIP",
calc = "CALC",
spell = "SPELL",
emoji = "EMOJI"
}
}
},
experimental = {native_menu = false, ghost_text = false},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
--luasnip.lsp_expand(args.body)
--require('luasnip').lsp_expand(args.body)
cmp.setup({
completion = {
completeopt = "menu,menuone,preview",
},
snippet = { -- configure how nvim-cmp interacts with snippet engine
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<C-e>"] = cmp.mapping.abort(), -- close completion window
["<CR>"] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }),
["<C-b>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true
},
-- Accept ([y]es) the completions.
['<C-y'] = cmp.mapping.confirm { select = true },
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- if cmp.visible() then
-- cmp.select_next_item()
-- -- elseif luasnip.expandable() then
-- -- luasnip.expand()
-- -- elseif luasnip.expand_or_jumpable() then
-- -- luasnip.expand_or_jump()
-- elseif has_words_before() then
-- cmp.complete()
-- else
-- fallback()
-- end
-- end, {"i", "s"}),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
-- elseif vim.fn["vsnip#jumpable"](-1) == 1 then
-- feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, {"i", "s"})
},
sources = {
{name = "nvim_lsp"},
{name = "buffer", keyword_length = 5},
{name = 'luasnip', option = { show_autosnippets = true } },
{name = "calc"},
{name = "emoji"},
{name = "spell"},
{name = "path"}
}
end, { "i", "s" }),
["<C-f>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
}),
-- sources for autocompletion
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" }, -- snippets
{ name = "buffer" }, -- text within current buffer
{ name = "path" }, -- file system paths
{ name = "calc" },
{ name = "emoji" },
{ name = "spell" },
}),
-- configure lspkind for vs-code like pictograms in completion menu
formatting = {
expandable_indicator = true,
fields = { 'abbr', 'kind', 'menu' },
format = lspkind.cmp_format({
maxwidth = 50,
ellipsis_char = "...",
}),
},
})
-- Use buffer source for `/`.
cmp.setup.cmdline("/", {sources = {{name = "buffer"}}})
-- Use cmdline & path source for ':'.
cmp.setup.cmdline(":", {
sources = cmp.config.sources({{name = "path"}}, {{name = "cmdline"}})
})
end
}
end,
}

View File

@@ -70,14 +70,18 @@ return {
-- Configure keybindings once we've attached.
local wk = require('which-key')
-- Normal mode keymaps
wk.add({
{ "<C-k>", vim.lsp.buf.hover, desc = "LSP hover info" },
{ "<leader>ca", vim.lsp.buf.code_action, desc = "LSP [C]ode [A]ction" },
{ "gd", vim.lsp.buf.definition, desc = "[G]oto [D]efinition" },
{ "gD", vim.lsp.buf.declaration, desc = "[G]oto [D]eclaration" },
{ "gi", vim.lsp.buf.implementation, desc = "[G]oto [I]mplementation" },
{ "gr", vim.lsp.buf.references, desc = "List [R]eferences" },
{"gs", vim.lsp.buf.signature_help, desc = "[S]ignature help" },
{ "<space>rn", vim.lsp.buf.rename, desc = "[R]e[N]ame" },
{ "<leader>rn", vim.lsp.buf.rename, desc = "[R]e[N]ame" },
{ "<leader>rl", ":LspRestart | :LspStart<CR>", desc = "[R]estart or start lsp." },
{ "<leader><leader>d", "<CMD>Telescope diagnostics bufnr=0<CR>", desc = "[D]iagnostics" },
{ "[d", vim.diagnostic.goto_prev, desc = "Go to previous diagnostic" },
{ "]d", vim.diagnostic.goto_prev, desc = "Go to next diagnostic" },
}, {
@@ -85,6 +89,13 @@ return {
silent = true,
noremap = true
})
-- Visual mode keymaps
wk.add({
{ "<leader>ca", vim.lsp.buf.code_action, desc = "LSP [C]ode [A]ction" },
},
{ mode = 'v', silent = true }
)
end,
})
end

View File

@@ -59,6 +59,28 @@ return {
return ''
end
local function xcodebuild_device()
if vim.g.xcodebuild_platform == "macOS" then
return " macOS"
end
local deviceIcon = ""
if vim.g.xcodebuild_platform:match("watch") then
deviceIcon = "􀟤"
elseif vim.g.xcodebuild_platform:match("tv") then
deviceIcon = "􀡴 "
elseif vim.g.xcodebuild_platform:match("vision") then
deviceIcon = "􁎖 "
end
if vim.g.xcodebuild_os then
return deviceIcon .. " " .. vim.g.xcodebuild_device_name .. " (" .. vim.g.xcodebuild_os .. ")"
end
return deviceIcon .. " " .. vim.g.xcodebuild_device_name
end
require('lualine').setup {
options = {
theme = 'auto',
@@ -104,7 +126,11 @@ return {
},
},
lualine_c = {},
lualine_x = {},
lualine_x = {
{ "' ' .. vim.g.xcodebuild_last_status", color = { fg = "Gray" } },
{ "'󰙨 ' .. vim.g.xcodebuild_test_plan", color = { fg = "#a6e3a1", bg = "#161622" } },
{ xcodebuild_device, color = { fg = "#f9e2af", bg = "#161622" } },
},
lualine_y = { search_result, 'filetype' },
lualine_z = { '%l:%c', '%p%%/%L' },
},

View File

@@ -19,6 +19,6 @@ return {
vim.keymap.set("n", "<leader>ml", function()
require("lint").try_lint()
end, { desc = "Lint file" })
end, { desc = "[L]int file" })
end,
}

View File

@@ -1,5 +1,15 @@
return {
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
opts = { }
opts = { },
config = function()
require('todo-comments').setup({})
vim.keymap.set('n', '<leader>tq', '<CMD>TodoQuickFix<CR>',
{ desc = "[T]odo [Q]uick fix list." }
)
vim.keymap.set('n', '<leader><leader>t', '<CMD>TodoTelescope<CR>',
{ desc = "[T]odo [Q]uick fix list." }
)
end,
}

View File

@@ -0,0 +1,24 @@
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
event = { "BufReadPre", "BufNewFile" },
keys = {
{ "<leader>tt", "<cmd>Trouble quickfix toggle<cr>", { desc = "Open a quickfix" } },
},
opts = {},
config = function()
require("trouble").setup({
auto_open = false,
auto_close = false,
auto_preview = true,
auto_jump = false,
mode = "quickfix",
severity = vim.diagnostic.severity.ERROR,
cycle_results = false,
})
-- Jump to diagnostic issues across the whole project.
vim.keymap.set("n", "<A-d>", "<cmd>silent cc | silent cn<cr>zz", { desc = "Jump to next issue" })
vim.keymap.set("n", "<A-s>", "<cmd>silent cc | silent cp<cr>zz", { desc = "Jump to previous issue" })
end,
}