Update zk mappings
This commit is contained in:
parent
65baac297f
commit
8f826f1f6f
@ -32,8 +32,9 @@ map('i', '?', '?<c-g>u', {noremap = true})
|
|||||||
-- gitsigns
|
-- gitsigns
|
||||||
map('', '<leader>gs', ':Gitsigns toggle_signs<cr>', {silent = true})
|
map('', '<leader>gs', ':Gitsigns toggle_signs<cr>', {silent = true})
|
||||||
-- lsp stuff
|
-- lsp stuff
|
||||||
vim.api.nvim_buf_set_keymap(0, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>',
|
map('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>',
|
||||||
{noremap = true})
|
{silent = false, noremap = true})
|
||||||
|
map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', {noremap = true})
|
||||||
map('', '<leader>K', '<cmd>lua vim.diagnostic.open_float()<CR>',
|
map('', '<leader>K', '<cmd>lua vim.diagnostic.open_float()<CR>',
|
||||||
{noremap = true})
|
{noremap = true})
|
||||||
map('', '<leader>qf',
|
map('', '<leader>qf',
|
||||||
|
@ -17,3 +17,37 @@ require("zk").setup({
|
|||||||
auto_attach = {enabled = true, filetypes = {"markdown"}}
|
auto_attach = {enabled = true, filetypes = {"markdown"}}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- mappings
|
||||||
|
-- Add the key mappings only for Markdown files in a zk notebook.
|
||||||
|
if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
|
||||||
|
local map = vim.api.nvim_set_keymap
|
||||||
|
local opts = {noremap = true, silent = false}
|
||||||
|
|
||||||
|
-- Open the link under the caret.
|
||||||
|
map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
|
|
||||||
|
-- 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.
|
||||||
|
map("n", "<leader>zn",
|
||||||
|
"<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
|
||||||
|
opts)
|
||||||
|
-- Create a new note in the same directory as the current buffer, using the current selection for title.
|
||||||
|
map("v", "<leader>znt",
|
||||||
|
":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }<CR>",
|
||||||
|
opts)
|
||||||
|
-- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title.
|
||||||
|
map("v", "<leader>znc",
|
||||||
|
":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
|
||||||
|
opts)
|
||||||
|
|
||||||
|
-- Open notes linking to the current buffer.
|
||||||
|
map("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", opts)
|
||||||
|
-- Alternative for backlinks using pure LSP and showing the source context.
|
||||||
|
-- map('n', '<leader>zb', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
|
-- Open notes linked by the current buffer.
|
||||||
|
map("n", "<leader>zl", "<Cmd>ZkLinks<CR>", opts)
|
||||||
|
|
||||||
|
-- Open the code actions for a visual selection.
|
||||||
|
map("v", "<leader>za", ":'<,'>lua vim.lsp.buf.range_code_action()<CR>", opts)
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user