diff --git a/ftplugin/markdown.lua b/ftplugin/markdown.lua index d827759..c13ca46 100644 --- a/ftplugin/markdown.lua +++ b/ftplugin/markdown.lua @@ -1,8 +1,9 @@ -- Add the key mappings only for Markdown files in a zk notebook. -if require('zk.util').notebook_root(vim.fn.expand('%:p')) ~= nil then +-- if require('zk.util').notebook_root(vim.fn.expand('%:p')) ~= nil then local function map(...) vim.api.nvim_buf_set_keymap(0, ...) end local opts = { noremap = true, silent = false } + map("n", "", "lua vim.lsp.buf.definition()", opts) -- Create a new note after asking for its title. -- This overrides the global `zn` mapping to create the note in the same directory as the current buffer. vim.keymap.set('n', 'zn', "ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", @@ -25,4 +26,4 @@ if require('zk.util').notebook_root(vim.fn.expand('%:p')) ~= nil then map('n', 'K', 'lua vim.lsp.buf.hover()', opts) -- Open the code actions for a visual selection. map('v', 'za', ":'<,'>lua vim.lsp.buf.range_code_action()", opts) -end +-- end diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 5e286c3..59d741f 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -298,6 +298,11 @@ return { on_attach = on_attach, } + lspconfig['zk'].setup { + capabilities = capabilities, + on_attach = on_attach, + } + lspconfig['yamlls'].setup { capabilities = capabilities, on_attach = on_attach, diff --git a/lua/plugins/zk.lua b/lua/plugins/zk.lua index dc225f1..747ee84 100644 --- a/lua/plugins/zk.lua +++ b/lua/plugins/zk.lua @@ -3,9 +3,24 @@ return { config = function() require('zk').setup({ picker = 'telescope', - config = { - on_attach = require('plugins.lspconfig').on_attach - } + -- config = { + -- on_attach = require('plugins.lspconfig').on_attach + -- } + lsp = { + -- `config` is passed to `vim.lsp.start_client(config)` + config = { + cmd = { 'zk', 'lsp' }, + name = 'zk', + -- on_attach = ... + -- etc, see `:h vim.lsp.start_client()` + }, + + -- automatically attach buffers in a zk notebook that match the given filetypes + auto_attach = { + enabled = true, + filetypes = { 'markdown' }, + }, + }, }) end }