99 lines
2.3 KiB
Lua
99 lines
2.3 KiB
Lua
---@module "utils.plugins"
|
|
---@type Plugin
|
|
return {
|
|
after = "mason",
|
|
configure = function(load)
|
|
load("neovim/nvim-lspconfig")
|
|
|
|
load("folke/lazydev.nvim")
|
|
require("lazydev").setup({})
|
|
|
|
--[[
|
|
---@type vim.lsp.Config
|
|
local config = {
|
|
---@type lspconfig.settings.lua_ls
|
|
settings = {
|
|
Lua = {
|
|
runtime = {
|
|
version = "LuaJIT",
|
|
},
|
|
workspace = {
|
|
preloadFileSize = 10000,
|
|
library = {
|
|
vim.env.VIMRUNTIME,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
vim.lsp.config("lua_ls", config)
|
|
]]
|
|
--
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
callback = function(args)
|
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
if client and client:supports_method("textDocument/completion") then
|
|
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
|
|
end
|
|
end,
|
|
})
|
|
vim.opt.completeopt = { "menuone", "noinsert", "popup" }
|
|
vim.keymap.set("i", "<Tab>", function()
|
|
if vim.fn.pumvisible() == 1 then
|
|
return "<C-y>"
|
|
end
|
|
return "<Tab>"
|
|
end, { expr = true })
|
|
|
|
-- Reserve a space in the gutter
|
|
-- This will avoid an annoying layout shift in the screen
|
|
vim.opt.signcolumn = "yes"
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
desc = "LSP actions",
|
|
callback = function(event)
|
|
local opts = { buffer = event.buf }
|
|
|
|
vim.keymap.set("n", "K", function()
|
|
vim.lsp.buf.hover()
|
|
end, opts)
|
|
vim.keymap.set("n", "gd", function()
|
|
vim.lsp.buf.definition()
|
|
end, opts)
|
|
vim.keymap.set("n", "gD", function()
|
|
vim.lsp.buf.declaration()
|
|
end, opts)
|
|
vim.keymap.set("n", "gi", function()
|
|
vim.lsp.buf.implementation()
|
|
end, opts)
|
|
vim.keymap.set("n", "go", function()
|
|
vim.lsp.buf.type_definition()
|
|
end, opts)
|
|
vim.keymap.set("n", "gr", function()
|
|
vim.lsp.buf.references()
|
|
end, opts)
|
|
vim.keymap.set("n", "gs", function()
|
|
vim.lsp.buf.signature_help()
|
|
end, opts)
|
|
vim.keymap.set("n", "<F2>", function()
|
|
vim.lsp.buf.rename()
|
|
end, opts)
|
|
vim.keymap.set({ "n", "x" }, "<F3>", function()
|
|
vim.lsp.buf.format({ async = true })
|
|
end, opts)
|
|
vim.keymap.set("n", "<leader>f", function()
|
|
vim.lsp.buf.code_action()
|
|
end, opts)
|
|
end,
|
|
})
|
|
|
|
load("mason-org/mason-lspconfig.nvim")
|
|
|
|
require("mason-lspconfig").setup({
|
|
automatic_enable = true,
|
|
})
|
|
|
|
load("LukasPietzschmann/boo.nvim")
|
|
end,
|
|
}
|