1
0
Fork 0

set up zk stuff

This commit is contained in:
Luca Bilke 2024-01-28 15:04:25 +01:00
commit c293c29af3
6 changed files with 42 additions and 44 deletions
.config/nvim/lua

View file

@ -212,46 +212,46 @@ end
function M.lsp_on_attach(client, bufnr)
local lsp_mappings = M.empty_map_table()
lsp_mappings.n["<leader>ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
lsp_mappings.n["<Leader>ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
lsp_mappings.n["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" }
lsp_mappings.n["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" }
lsp_mappings.n["gl"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
if M.is_available("telescope.nvim") then
lsp_mappings.n["<leader>lD"] = {
lsp_mappings.n["<Leader>lD"] = {
function() require("telescope.builtin").diagnostics() end,
desc = "Search diagnostics",
}
end
if M.is_available("mason-lspconfig.nvim") then
lsp_mappings.n["<leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" }
lsp_mappings.n["<Leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" }
end
if M.is_available("none-ls.nvim") then
lsp_mappings.n["<leader>lI"] = { "<cmd>NullLsInfo<cr>", desc = "Null-ls information" }
lsp_mappings.n["<Leader>lI"] = { "<cmd>NullLsInfo<cr>", desc = "Null-ls information" }
end
if client.supports_method("textDocument/codeAction") then
lsp_mappings.n["<leader>la"] = {
lsp_mappings.n["<Leader>la"] = {
function() vim.lsp.buf.code_action() end,
desc = "Code action",
}
lsp_mappings.v["<leader>la"] = lsp_mappings.n["<leader>la"]
lsp_mappings.v["<Leader>la"] = lsp_mappings.n["<Leader>la"]
end
if client.supports_method("textDocument/codeLens") then
vim.lsp.codelens.refresh()
lsp_mappings.n["<leader>ll"] = {
lsp_mappings.n["<Leader>ll"] = {
function() vim.lsp.codelens.refresh() end,
desc = "Refresh CodeLens",
}
lsp_mappings.n["<leader>lL"] = {
lsp_mappings.n["<Leader>lL"] = {
function() vim.lsp.codelens.run() end,
desc = "Run CodeLens",
}
lsp_mappings.n["<Leader>u"] = { desc = icons.Gear .. " Utility" }
lsp_mappings.n["<leader>uL"] = {
lsp_mappings.n["<Leader>uL"] = {
function() vim.lsp.codelens.clear() end,
desc = "Toggle CodeLens"
}
@ -293,14 +293,14 @@ function M.lsp_on_attach(client, bufnr)
end
if client.supports_method "workspace/symbol" then
lsp_mappings.n["<leader>lG"] = {
lsp_mappings.n["<Leader>lG"] = {
function() vim.lsp.buf.workspace_symbol() end,
desc = "List symbols"
}
end
if client.supports_method "textDocument/rename" then
lsp_mappings.n["<leader>lr"] = {
lsp_mappings.n["<Leader>lr"] = {
function() vim.lsp.buf.rename() end,
desc = "Rename symbol",
}
@ -310,7 +310,7 @@ function M.lsp_on_attach(client, bufnr)
if client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens then
vim.b[bufnr].semantic_tokens_enabled = true
lsp_mappings.n["<Leader>u"] = { desc = icons.Gear .. " Utility" }
lsp_mappings.n["<leader>uY"] = {
lsp_mappings.n["<Leader>uY"] = {
function()
vim.b[bufnr].semantic_tokens_enabled = not vim.b[bufnr].semantic_tokens_enabled
for _, active_client in ipairs(vim.lsp.get_active_clients { bufnr = bufnr }) do
@ -325,7 +325,7 @@ function M.lsp_on_attach(client, bufnr)
end
if client.supports_method("textDocument/formatting") then
lsp_mappings.n["<leader>lf"] = {
lsp_mappings.n["<Leader>lf"] = {
function()
vim.lsp.buf.format({
filter = function(c)
@ -343,7 +343,7 @@ function M.lsp_on_attach(client, bufnr)
end,
desc = "Format buffer",
}
lsp_mappings.v["<leader>lf"] = lsp_mappings.n["<leader>lf"]
lsp_mappings.v["<Leader>lf"] = lsp_mappings.n["<Leader>lf"]
end
if client.supports_method("textDocument/documentHighlight") then
@ -383,7 +383,7 @@ function M.lsp_on_attach(client, bufnr)
if vim.lsp.inlay_hint then
if vim.b.inlay_hints_enabled then vim.lsp.inlay_hint.enable(bufnr, true) end
lsp_mappings.n["<Leader>u"] = { desc = icons.Gear .. " Utility" }
lsp_mappings.n["<leader>uH"] = {
lsp_mappings.n["<Leader>uH"] = {
function()
vim.b[bufnr].inlay_hints_enabled = not vim.b[bufnr].inlay_hints_enabled
if vim.lsp.inlay_hint then
@ -396,7 +396,7 @@ function M.lsp_on_attach(client, bufnr)
end
if client.supports_method "textDocument/signatureHelp" then
lsp_mappings.n["<leader>lh"] = {
lsp_mappings.n["<Leader>lh"] = {
function() vim.lsp.buf.signature_help() end,
desc = "Signature help",
}
@ -412,14 +412,14 @@ function M.lsp_on_attach(client, bufnr)
if lsp_mappings.n.gr then
lsp_mappings.n.gr[1] = function() require("telescope.builtin").lsp_references() end
end
if lsp_mappings.n["<leader>lR"] then
lsp_mappings.n["<leader>lR"][1] = function() require("telescope.builtin").lsp_references() end
if lsp_mappings.n["<Leader>lR"] then
lsp_mappings.n["<Leader>lR"][1] = function() require("telescope.builtin").lsp_references() end
end
if lsp_mappings.n.gy then
lsp_mappings.n.gy[1] = function() require("telescope.builtin").lsp_type_definitions() end
end
if lsp_mappings.n["<leader>lG"] then
lsp_mappings.n["<leader>lG"][1] = function()
if lsp_mappings.n["<Leader>lG"] then
lsp_mappings.n["<Leader>lG"][1] = function()
vim.ui.input({ prompt = "Symbol Query: (leave empty for word under cursor)" }, function(query)
if query then
-- word under cursor if given query is empty
@ -435,14 +435,14 @@ function M.lsp_on_attach(client, bufnr)
end
if not vim.tbl_isempty(lsp_mappings.v) then
if lsp_mappings.v["<leader>l"] then lsp_mappings.v["<leader>l"] = { desc = icons.Code .. " LSP" } end
if lsp_mappings.v["<leader>u"] then lsp_mappings.v["<leader>u"] = { desc = icons.Code .. " LSP" } end
if lsp_mappings.v["<Leader>l"] then lsp_mappings.v["<Leader>l"] = { desc = icons.Code .. " LSP" } end
if lsp_mappings.v["<Leader>u"] then lsp_mappings.v["<Leader>u"] = { desc = icons.Code .. " LSP" } end
end
M.set_maps(lsp_mappings, { buffer = bufnr })
end
function M.has_value (table, value)
function M.has_value(table, value)
for _, v in ipairs(table) do
if v == value then
return true