nvim lua lsp
This commit is contained in:
+85
-23
@@ -41,7 +41,7 @@ require("lazy").setup({
|
|||||||
vim.g.tmux_navigator_no_mappings = 1
|
vim.g.tmux_navigator_no_mappings = 1
|
||||||
vim.g.tmux_navigator_disable_when_zoomed = 1
|
vim.g.tmux_navigator_disable_when_zoomed = 1
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
opts = { silent = true, noremap = true }
|
local opts = { silent = true, noremap = true }
|
||||||
map("n", "<M-h>", ":TmuxNavigateLeft<cr>", opts)
|
map("n", "<M-h>", ":TmuxNavigateLeft<cr>", opts)
|
||||||
map("n", "<M-j>", ":TmuxNavigateDown<cr>", opts)
|
map("n", "<M-j>", ":TmuxNavigateDown<cr>", opts)
|
||||||
map("n", "<M-k>", ":TmuxNavigateUp<cr>", opts)
|
map("n", "<M-k>", ":TmuxNavigateUp<cr>", opts)
|
||||||
@@ -148,8 +148,8 @@ require("lazy").setup({
|
|||||||
},
|
},
|
||||||
{ "diff", colored = true },
|
{ "diff", colored = true },
|
||||||
},
|
},
|
||||||
lualine_x = { "filetype" },
|
lualine_x = {},
|
||||||
lualine_y = { "progress" },
|
lualine_y = { "filetype", "progress" },
|
||||||
lualine_z = { "location" },
|
lualine_z = { "location" },
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
@@ -165,7 +165,7 @@ require("lazy").setup({
|
|||||||
{ "diff", colored = true },
|
{ "diff", colored = true },
|
||||||
},
|
},
|
||||||
lualine_x = {},
|
lualine_x = {},
|
||||||
lualine_y = { "progress" },
|
lualine_y = { "filetype", "progress" },
|
||||||
lualine_z = { "location" },
|
lualine_z = { "location" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -188,7 +188,7 @@ require("lazy").setup({
|
|||||||
config = function()
|
config = function()
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
map("", "<C-g>", ":vertical Git<cr>:vertical resize 60<cr>", {})
|
map("", "<C-g>", ":vertical Git<cr>:vertical resize 60<cr>", {})
|
||||||
map("", "<leader>gb", ":Git blame<cr>", {})
|
map("", "<leader>gB", ":Git blame<cr>", {})
|
||||||
map("", "<leader>gp", ":Git push<cr>", {})
|
map("", "<leader>gp", ":Git push<cr>", {})
|
||||||
map("", "<leader>gP", ":Git push -f<cr>", {})
|
map("", "<leader>gP", ":Git push -f<cr>", {})
|
||||||
end,
|
end,
|
||||||
@@ -208,12 +208,14 @@ require("lazy").setup({
|
|||||||
signcolumn = true,
|
signcolumn = true,
|
||||||
numhl = true,
|
numhl = true,
|
||||||
linehl = false,
|
linehl = false,
|
||||||
word_diff = true,
|
word_diff = false,
|
||||||
on_attach = function(bufnr)
|
on_attach = function(bufnr)
|
||||||
local gs = package.loaded.gitsigns
|
local gs = package.loaded.gitsigns
|
||||||
|
|
||||||
local function map(mode, l, r)
|
local function map(mode, l, r, opts)
|
||||||
vim.keymap.set(mode, l, r, { buffer = bufnr })
|
opts = opts or {}
|
||||||
|
opts.buffer = bufnr
|
||||||
|
vim.keymap.set(mode, l, r, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Navigation
|
-- Navigation
|
||||||
@@ -239,7 +241,7 @@ require("lazy").setup({
|
|||||||
|
|
||||||
-- Actions
|
-- Actions
|
||||||
map({ "n", "v" }, "<leader>gs", ":Gitsigns stage_hunk<CR>")
|
map({ "n", "v" }, "<leader>gs", ":Gitsigns stage_hunk<CR>")
|
||||||
map({ "n", "v" }, "<leader>xr", ":Gitsigns reset_hunk<CR>")
|
map({ "n", "v" }, "<leader>gx", ":Gitsigns reset_hunk<CR>")
|
||||||
map("n", "<leader>gu", gs.undo_stage_hunk)
|
map("n", "<leader>gu", gs.undo_stage_hunk)
|
||||||
map("n", "<leader>gi", gs.preview_hunk)
|
map("n", "<leader>gi", gs.preview_hunk)
|
||||||
map("n", "<leader>gb", function()
|
map("n", "<leader>gb", function()
|
||||||
@@ -340,6 +342,7 @@ require("lazy").setup({
|
|||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
version = "*",
|
version = "*",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
"sharkdp/fd",
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
"nvim-telescope/telescope-live-grep-args.nvim",
|
"nvim-telescope/telescope-live-grep-args.nvim",
|
||||||
},
|
},
|
||||||
@@ -501,21 +504,34 @@ require("lazy").setup({
|
|||||||
"jose-elias-alvarez/null-ls.nvim",
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
dependencies = { "nvim-lua/plenary.nvim" },
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
config = function()
|
config = function()
|
||||||
|
-- local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
null_ls.setup({
|
null_ls.setup({
|
||||||
sources = {
|
sources = {
|
||||||
null_ls.builtins.completion.spell,
|
|
||||||
null_ls.builtins.diagnostics.mypy,
|
null_ls.builtins.diagnostics.mypy,
|
||||||
null_ls.builtins.diagnostics.eslint_d,
|
null_ls.builtins.diagnostics.eslint_d,
|
||||||
null_ls.builtins.formatting.black.with({ extra_args = { "--preview" }, }),
|
null_ls.builtins.formatting.black.with({ extra_args = { "--preview" } }),
|
||||||
null_ls.builtins.formatting.eslint_d,
|
null_ls.builtins.formatting.eslint_d,
|
||||||
null_ls.builtins.formatting.isort,
|
null_ls.builtins.formatting.isort,
|
||||||
null_ls.builtins.formatting.jq,
|
null_ls.builtins.formatting.jq,
|
||||||
null_ls.builtins.formatting.prettierd,
|
null_ls.builtins.formatting.prettierd,
|
||||||
null_ls.builtins.formatting.shfmt.with({ extra_args = { "--indent", "4" }, }),
|
null_ls.builtins.formatting.shfmt.with({ extra_args = { "--indent", "4" } }),
|
||||||
|
null_ls.builtins.formatting.stylua.with({ extra_args = { "--indent-type", "Spaces" } }),
|
||||||
null_ls.builtins.formatting.yamlfmt,
|
null_ls.builtins.formatting.yamlfmt,
|
||||||
null_ls.builtins.formatting.yq,
|
null_ls.builtins.formatting.yq,
|
||||||
},
|
},
|
||||||
|
-- on_attach = function(client, bufnr)
|
||||||
|
-- if client.supports_method("textDocument/formatting") then
|
||||||
|
-- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
|
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
-- group = augroup,
|
||||||
|
-- buffer = bufnr,
|
||||||
|
-- callback = function()
|
||||||
|
-- vim.lsp.buf.format({ bufnr = bufnr })
|
||||||
|
-- end,
|
||||||
|
-- })
|
||||||
|
-- end
|
||||||
|
-- end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@@ -529,7 +545,7 @@ require("lazy").setup({
|
|||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
local bmap = function(mode, keys, func)
|
local bmap = function(mode, keys, func)
|
||||||
vim.keymap.set(mode, keys, func, { buffer = bufnr, noremap = true })
|
vim.keymap.set(mode, keys, func, { buffer = bufnr, noremap = true })
|
||||||
end
|
end
|
||||||
@@ -541,9 +557,15 @@ require("lazy").setup({
|
|||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
end)
|
end)
|
||||||
-- jump
|
-- jump
|
||||||
bmap("n", "<M-i>", vim.diagnostic.open_float)
|
bmap("n", "<M-i>", function()
|
||||||
bmap("n", "<M-n>", vim.diagnostic.goto_next)
|
vim.diagnostic.open_float({ source = true })
|
||||||
bmap("n", "<M-p>", vim.diagnostic.goto_prev)
|
end)
|
||||||
|
bmap("n", "<M-n>", function()
|
||||||
|
vim.diagnostic.goto_next({ severity = { min = vim.diagnostic.severity.INFO } })
|
||||||
|
end)
|
||||||
|
bmap("n", "<M-p>", function()
|
||||||
|
vim.diagnostic.goto_prev({ severity = { min = vim.diagnostic.severity.INFO } })
|
||||||
|
end)
|
||||||
bmap("n", "gd", vim.lsp.buf.definition)
|
bmap("n", "gd", vim.lsp.buf.definition)
|
||||||
bmap("n", "gD", vim.lsp.buf.type_definition)
|
bmap("n", "gD", vim.lsp.buf.type_definition)
|
||||||
bmap("n", "gi", vim.lsp.buf.declaration)
|
bmap("n", "gi", vim.lsp.buf.declaration)
|
||||||
@@ -556,18 +578,18 @@ require("lazy").setup({
|
|||||||
-- other
|
-- other
|
||||||
bmap("n", "K", vim.lsp.buf.hover)
|
bmap("n", "K", vim.lsp.buf.hover)
|
||||||
bmap("n", "<M-r>", vim.lsp.buf.rename)
|
bmap("n", "<M-r>", vim.lsp.buf.rename)
|
||||||
bmap("n", "<leader>f", vim.lsp.buf.format)
|
|
||||||
bmap("n", "<leader>ca", vim.lsp.buf.code_action)
|
bmap("n", "<leader>ca", vim.lsp.buf.code_action)
|
||||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
||||||
vim.lsp.buf.format()
|
vim.lsp.buf.format({ timeout_ms = 5000 })
|
||||||
end, { desc = "Format current buffer with LSP" })
|
end, { desc = "Format current buffer with LSP" })
|
||||||
|
bmap("n", "<leader>f", ":Format<cr>")
|
||||||
if
|
if
|
||||||
client.server_capabilities.documentFormattingProvider
|
client.server_capabilities.documentFormattingProvider
|
||||||
or client.server_capabilities.documentRangeFormattingProvider
|
or client.server_capabilities.documentRangeFormattingProvider
|
||||||
then
|
then
|
||||||
vim.api.nvim_command([[augroup Format]])
|
vim.api.nvim_command([[augroup Format]])
|
||||||
vim.api.nvim_command([[autocmd! * <buffer>]])
|
vim.api.nvim_command([[autocmd! * <buffer>]])
|
||||||
vim.api.nvim_command([[autocmd BufWritePre * lua vim.lsp.buf.format()]])
|
vim.api.nvim_command([[autocmd BufWritePre * lua vim.lsp.buf.format({ timeout_ms = 5000 })]])
|
||||||
vim.api.nvim_command([[augroup END]])
|
vim.api.nvim_command([[augroup END]])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -586,8 +608,19 @@ require("lazy").setup({
|
|||||||
},
|
},
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
Lua = {
|
Lua = {
|
||||||
workspace = { checkThirdParty = false },
|
workspace = {
|
||||||
|
checkThirdParty = false,
|
||||||
|
-- Make the server aware of Neovim runtime files
|
||||||
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
|
},
|
||||||
telemetry = { enable = false },
|
telemetry = { enable = false },
|
||||||
|
diagnostics = {
|
||||||
|
-- Get the language server to recognize the `vim` global
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
format = { -- disable formatting, stylua handles it
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
marksman = {},
|
marksman = {},
|
||||||
@@ -597,7 +630,6 @@ require("lazy").setup({
|
|||||||
html = {},
|
html = {},
|
||||||
eslint = {},
|
eslint = {},
|
||||||
dockerls = {},
|
dockerls = {},
|
||||||
docker_compose_language_service = {},
|
|
||||||
cssls = {},
|
cssls = {},
|
||||||
bashls = {},
|
bashls = {},
|
||||||
}
|
}
|
||||||
@@ -622,6 +654,33 @@ require("lazy").setup({
|
|||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"folke/noice.nvim",
|
||||||
|
config = function()
|
||||||
|
require("noice").setup({
|
||||||
|
lsp = {
|
||||||
|
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
|
||||||
|
override = {
|
||||||
|
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||||
|
["vim.lsp.util.stylize_markdown"] = true,
|
||||||
|
["cmp.entry.get_documentation"] = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- you can enable a preset for easier configuration
|
||||||
|
presets = {
|
||||||
|
bottom_search = false, -- use a classic bottom cmdline for search
|
||||||
|
command_palette = true, -- position the cmdline and popupmenu together
|
||||||
|
long_message_to_split = true, -- long messages will be sent to a split
|
||||||
|
inc_rename = false, -- enables an input dialog for inc-rename.nvim
|
||||||
|
lsp_doc_border = false, -- add a border to hover docs and signature help
|
||||||
|
},
|
||||||
|
messages = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
dependencies = { "MunifTanjim/nui.nvim" },
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- ----------------------------------------
|
-- ----------------------------------------
|
||||||
@@ -731,7 +790,7 @@ local cmd = vim.cmd
|
|||||||
|
|
||||||
vim.api.nvim_command([[augroup MYAU]])
|
vim.api.nvim_command([[augroup MYAU]])
|
||||||
vim.api.nvim_command([[autocmd!]])
|
vim.api.nvim_command([[autocmd!]])
|
||||||
vim.api.nvim_command([[autocmd BufWritePost * %s/\s\+$//e]])
|
vim.api.nvim_command([[autocmd BufWritePre * %s/\s\+$//e]])
|
||||||
vim.api.nvim_command([[autocmd FileType python setlocal indentkeys-=<:>]])
|
vim.api.nvim_command([[autocmd FileType python setlocal indentkeys-=<:>]])
|
||||||
vim.api.nvim_command([[autocmd BufReadPost quickfix nmap <buffer> <cr> <cr>]])
|
vim.api.nvim_command([[autocmd BufReadPost quickfix nmap <buffer> <cr> <cr>]])
|
||||||
vim.api.nvim_command([[augroup END]])
|
vim.api.nvim_command([[augroup END]])
|
||||||
@@ -804,4 +863,7 @@ map("n", "<F3>", ":LspInfo<cr>", { noremap = true })
|
|||||||
map("n", "<F4>", ":NullLsInfo<cr>", { noremap = true })
|
map("n", "<F4>", ":NullLsInfo<cr>", { noremap = true })
|
||||||
map("n", "<F5>", ":checkt<cr>", { noremap = true })
|
map("n", "<F5>", ":checkt<cr>", { noremap = true })
|
||||||
map("n", "<F6>", ":TodoQuickFix<cr>", { noremap = true })
|
map("n", "<F6>", ":TodoQuickFix<cr>", { noremap = true })
|
||||||
map("n", "<F9>", '<cmd>lua require("telescope.builtin").colorscheme({enable_preview=1})<cr>', opts)
|
map("n", "<F9>", '<cmd>lua require("telescope.builtin").colorscheme({enable_preview=1})<cr>', { noremap = true })
|
||||||
|
|
||||||
|
-- shit HACK
|
||||||
|
map("n", "<leader>b", ":!blackdoc %<cr>", { noremap = true })
|
||||||
|
|||||||
Reference in New Issue
Block a user