This commit is contained in:
Oliver Hartmann 2023-12-01 20:57:55 +01:00
parent 943f29a165
commit 9af61291c3
3 changed files with 26 additions and 5 deletions

View File

@ -1,8 +1,9 @@
-- Add the key mappings only for Markdown files in a zk notebook. -- 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 function map(...) vim.api.nvim_buf_set_keymap(0, ...) end
local opts = { noremap = true, silent = false } local opts = { noremap = true, silent = false }
map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
-- Create a new note after asking for its title. -- Create a new note after asking for its title.
-- This overrides the global `<leader>zn` mapping to create the note in the same directory as the current buffer. -- This overrides the global `<leader>zn` mapping to create the note in the same directory as the current buffer.
vim.keymap.set('n', '<leader>zn', "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>", vim.keymap.set('n', '<leader>zn', "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
@ -25,4 +26,4 @@ if require('zk.util').notebook_root(vim.fn.expand('%:p')) ~= nil then
map('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts) map('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
-- Open the code actions for a visual selection. -- Open the code actions for a visual selection.
map('v', '<leader>za', ":'<,'>lua vim.lsp.buf.range_code_action()<CR>", opts) map('v', '<leader>za', ":'<,'>lua vim.lsp.buf.range_code_action()<CR>", opts)
end -- end

View File

@ -298,6 +298,11 @@ return {
on_attach = on_attach, on_attach = on_attach,
} }
lspconfig['zk'].setup {
capabilities = capabilities,
on_attach = on_attach,
}
lspconfig['yamlls'].setup { lspconfig['yamlls'].setup {
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,

View File

@ -3,9 +3,24 @@ return {
config = function() config = function()
require('zk').setup({ require('zk').setup({
picker = 'telescope', picker = 'telescope',
-- config = {
-- on_attach = require('plugins.lspconfig').on_attach
-- }
lsp = {
-- `config` is passed to `vim.lsp.start_client(config)`
config = { config = {
on_attach = require('plugins.lspconfig').on_attach 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 end
} }