1
0
Fork 0

set up zk stuff

This commit is contained in:
Luca Bilke 2024-01-28 15:04:25 +01:00
parent 8012717ace
commit c293c29af3
6 changed files with 42 additions and 44 deletions

View File

@ -45,8 +45,18 @@ end
-- Notes -- -- Notes --
if f.is_available("zk-nvim") then if f.is_available("zk-nvim") then
maps.n["<Leader>n"] = M.sections.n maps.n["<Leader>n"] = M.sections.n
maps.n["<Leader>ni"] = { require("zk.commands").get("ZkIndex"), desc = "Index Notes" } maps.n["<Leader>nn"] = {
maps.n["<Leader>nn"] = { require("zk.commands").get("ZkIndex"), desc = "Index Notes" } function() require("zk").new({ notebook_path = vim.g.wikidir, title = vim.fn.input('Title: ') }) end,
desc = "New Note"
}
maps.n["<Leader>no"] = {
function() require("zk").edit({ notebook_path = vim.g.wikidir }) end,
desc = "Open Note"
}
maps.n["<Leader>ni"] = {
function() require("zk").index({ notebook_path = vim.g.wikidir }) end,
desc = "Index Notes"
}
end end
-- Window Navigation -- -- Window Navigation --
@ -180,7 +190,11 @@ if f.is_available("telescope.nvim") then
maps.n["<Leader>fr"] = { function() require("telescope.builtin").registers() end, desc = "Find registers" } maps.n["<Leader>fr"] = { function() require("telescope.builtin").registers() end, desc = "Find registers" }
maps.n["<Leader>fw"] = { function() require("telescope.builtin").live_grep() end, desc = "Find words" } maps.n["<Leader>fw"] = { function() require("telescope.builtin").live_grep() end, desc = "Find words" }
-- maps.n["<Leader>fb"] = { function() require("telescope.builtin").buffers() end, desc = "Find buffers" } -- maps.n["<Leader>fb"] = { function() require("telescope.builtin").buffers() end, desc = "Find buffers" }
maps.n["<Leader>ft"] = { function() require("telescope").extensions["todo-comments"].todo() end, desc = "Find buffers" } maps.n["<Leader>ft"] = {
function() require("telescope").extensions["todo-comments"].todo() end,
desc =
"Find buffers"
}
maps.n["<Leader>fW"] = { maps.n["<Leader>fW"] = {
function() function()
require("telescope.builtin").live_grep({ require("telescope.builtin").live_grep({

View File

@ -16,7 +16,7 @@ conf.handlers["bashls"] = {
} }
} }
conf.required = { "lua_ls" } conf.required = { "lua_ls", "zk" }
conf.ignore = { "rust_analyzer" } -- This will be setup by rustacean.nvim conf.ignore = { "rust_analyzer" } -- This will be setup by rustacean.nvim
return conf return conf

View File

@ -2,6 +2,7 @@ local g = vim.g
local o = vim.opt local o = vim.opt
local d = vim.diagnostic.config local d = vim.diagnostic.config
g.wikidir = os.getenv("XDG_DOCUMENTS_DIR") .. "/wiki"
g.mapleader = " " g.mapleader = " "
g.maplocalleader = " " g.maplocalleader = " "
g.vim_json_conceal = 0 g.vim_json_conceal = 0

View File

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

View File

@ -25,5 +25,4 @@ return {
require('plugins.misc.ufo'), require('plugins.misc.ufo'),
require('plugins.misc.vimtex'), require('plugins.misc.vimtex'),
require('plugins.misc.which-key'), require('plugins.misc.which-key'),
require('plugins.misc.wiki'),
} }

View File

@ -1,16 +0,0 @@
local M = { "lervag/wiki.vim" }
M.cmd = {
"WikiIndex",
"WikiJournal",
"WikiPages",
"WikiTags",
"WikiToc",
"WikiTocGenerate",
}
M.init = function()
vim.g.wiki_root = "~/Documents/wiki"
end
return M