Compare commits
5 Commits
73dfaec988
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ccc729ce7 | ||
| be94adda8a | |||
| 4f8489bfdb | |||
| d0e94ed5a7 | |||
| 3f2c2ce65f |
9
lsp/lua_ls.lua
Normal file
9
lsp/lua_ls.lua
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = { globals = { "vim" } },
|
||||||
|
workspace = { checkThirdParty = false },
|
||||||
|
telemetry = { enable = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -12,8 +12,8 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
|||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
vim.g.maplocalleader = " "
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
|
|||||||
@@ -28,3 +28,33 @@ map("n", "<S-Tab>", "<cmd>BufferLineCyclePrev<cr>", { desc = "Previous buffer" }
|
|||||||
map("n", "<leader>ba", "<cmd>BufferLineCloseOthers<CR>", { desc = "Close other buffers" })
|
map("n", "<leader>ba", "<cmd>BufferLineCloseOthers<CR>", { desc = "Close other buffers" })
|
||||||
map("n", "<leader>x", "<cmd>BufferLinePickClose<CR>", { desc = "Close buffer" })
|
map("n", "<leader>x", "<cmd>BufferLinePickClose<CR>", { desc = "Close buffer" })
|
||||||
map("n", "<leader>bc", "<cmd>BufferLinePick<CR>", { desc = "Close buffer" })
|
map("n", "<leader>bc", "<cmd>BufferLinePick<CR>", { desc = "Close buffer" })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(ev)
|
||||||
|
local bufnr = ev.buf
|
||||||
|
|
||||||
|
local opts = function(desc)
|
||||||
|
return { buffer = bufnr, silent = true, desc = desc }
|
||||||
|
end
|
||||||
|
|
||||||
|
map("n", "gd", vim.lsp.buf.definition, opts "LSP: Go to definition")
|
||||||
|
map("n", "gD", vim.lsp.buf.declaration, opts "LSP: Go to declaration")
|
||||||
|
map("n", "gi", vim.lsp.buf.implementation, opts "LSP: Go to implementation")
|
||||||
|
map("n", "gr", vim.lsp.buf.references, opts "LSP: References")
|
||||||
|
map("n", "K", vim.lsp.buf.hover, opts "LSP: Hover")
|
||||||
|
map("n", "<leader>rn", vim.lsp.buf.rename, opts "LSP: Rename")
|
||||||
|
map("n", "<leader>ca", vim.lsp.buf.code_action, opts "LSP: Code action")
|
||||||
|
|
||||||
|
map("n", "[d", function()
|
||||||
|
vim.diagnostic.jump { count = -1, float = true }
|
||||||
|
end, opts "Diag: Prev")
|
||||||
|
map("n", "]d", function()
|
||||||
|
vim.diagnostic.jump { count = 1, float = true }
|
||||||
|
end, opts "Diag: Next")
|
||||||
|
map("n", "<leader>dd", vim.diagnostic.open_float, opts "Diag: Line diagnostics")
|
||||||
|
|
||||||
|
map("n", "<leader>lf", function()
|
||||||
|
vim.lsp.buf.format { async = true }
|
||||||
|
end, opts "LSP: Format (server)")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|||||||
70
lua/plugins/cmp.lua
Normal file
70
lua/plugins/cmp.lua
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
event = "InsertEnter",
|
||||||
|
dependencies = {
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"hrsh7th/cmp-cmdline",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require "cmp"
|
||||||
|
local luasnip = require "luasnip"
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
mapping = cmp.mapping.preset.insert {
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||||
|
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
|
||||||
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
},
|
||||||
|
|
||||||
|
sources = cmp.config.sources {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "buffer" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cmp.setup.cmdline({ "/", "?" }, {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = { { name = "buffer" } },
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline(":", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline" } }),
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -17,6 +17,8 @@ return {
|
|||||||
opts = {
|
opts = {
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { "stylua" },
|
lua = { "stylua" },
|
||||||
|
yml = { "yamlfmt" },
|
||||||
|
yaml = { "yamlfmt" },
|
||||||
},
|
},
|
||||||
default_format_opts = {
|
default_format_opts = {
|
||||||
lsp_format = "fallback",
|
lsp_format = "fallback",
|
||||||
|
|||||||
18
lua/plugins/lsp.lua
Normal file
18
lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
dependencies = {
|
||||||
|
{ "hrsh7th/nvim-cmp" },
|
||||||
|
{ "j-hui/fidget.nvim", opts = {} },
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local caps = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
caps = require("cmp_nvim_lsp").default_capabilities(caps)
|
||||||
|
|
||||||
|
vim.lsp.config("*", { capabilities = caps })
|
||||||
|
vim.lsp.enable {
|
||||||
|
"lua_ls",
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -34,4 +34,20 @@ return {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
|
opts = {
|
||||||
|
move = {
|
||||||
|
enable = true,
|
||||||
|
set_jumps = true,
|
||||||
|
keys = {
|
||||||
|
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer", ["]a"] = "@parameter.inner" },
|
||||||
|
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer", ["]A"] = "@parameter.inner" },
|
||||||
|
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer", ["[a"] = "@parameter.inner" },
|
||||||
|
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer", ["[A"] = "@parameter.inner" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user