diff options
| author | Robert Günzler <r@gnzler.io> | 2022-02-08 23:50:44 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-02-08 23:50:44 +0100 |
| commit | 9cf344abe6583c655a89cc48d732ee91c3d2e4c6 (patch) | |
| tree | acf6c2014fb26504c82bece75673e136e35ae495 /.vim/lua | |
| parent | 6138a759778966253188a6a2f3b24f7f4927f879 (diff) | |
vim: install zk-nvim plugin
Diffstat (limited to '.vim/lua')
| -rw-r--r-- | .vim/lua/lsp.lua | 18 | ||||
| -rw-r--r-- | .vim/lua/plugins.lua | 22 | ||||
| -rw-r--r-- | .vim/lua/zk.lua | 47 |
3 files changed, 22 insertions, 65 deletions
diff --git a/.vim/lua/lsp.lua b/.vim/lua/lsp.lua index 2bb47b3..0f9e640 100644 --- a/.vim/lua/lsp.lua +++ b/.vim/lua/lsp.lua @@ -2,17 +2,6 @@ local lsp = require('lspconfig') -- local spinner_lsp = require('spinner.lsp') local lspstatus = require('lsp-status') -require('lspconfig/configs').zk = { - default_config = { - cmd = {'zk', 'lsp'}, - filetypes = {'markdown'}, - root_dir = function() - return vim.loop.cwd() - end, - settings = {}, - } -} - local my_attach = function(client, bufnr) if vim.opt.diff:get() then vim.notify('not running LSP client in diff mode') @@ -202,13 +191,6 @@ local setup = function() capabilities = caps, } - lsp.zk.setup { - on_attach = my_attach, - on_exit = my_exit, - capabilities = caps, - root_dir = lsp.util.root_pattern('.zk'), - } - end return { diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index 9b34790..1b7eb86 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -410,6 +410,7 @@ return require('packer').startup({function() -- required to get fzf-native working require('telescope').load_extension('fzf') require('telescope').load_extension('ui-select') + require('telescope').load_extension('zk') vim.keymap.set('n', ';Q', require('telescope.builtin').quickfix) vim.keymap.set('n', ';C', require('telescope.builtin').loclist) @@ -567,6 +568,27 @@ return require('packer').startup({function() -- vim.cmd [[ command! OrgmodeArchive lua require('orgmode').action('org_mappings.toggle_archive_tag') ]] end} -- }}} + use {'mickael-menu/zk-nvim', module = {'zk', 'telescope._extensions.zk'}, -- {{{ + config = function() + local lsp = require('lsp') + require('zk').setup { + picker = 'telescope', + lsp = { + config = { + cmd = {'/home/robert/devel/upstream/github.com/mickael-menu/zk/zk', 'lsp', '--log', '/tmp/zk-lsp.log'}, + on_attach = lsp.my_attach, + on_exit = lsp.my_exit, + capabilities = lsp.capabilities(), + }, + auto_attach = { + enabled = true, + filetypes = { 'markdown', 'norg' }, + }, + }, + } + vim.keymap.set('n', ';z', function() require('zk').edit(nil, { multi_select = false }) end) + end} -- }}} + -- languages -- NOTE: these should only be loaded when they are required... -- use {'rhysd/vim-grammarous', diff --git a/.vim/lua/zk.lua b/.vim/lua/zk.lua deleted file mode 100644 index 242badc..0000000 --- a/.vim/lua/zk.lua +++ /dev/null @@ -1,47 +0,0 @@ - -local function zk_new(path, title_dir) - path = path or vim.loop.cwd() - if not (path and #path > 0) then return end - - if not title_dir then - vim.ui.input('New Zettel: ', function(result) - title_dir = result - end) - end - if title_dir == "" then return end - - local o = {} - local parts = vim.split(title_dir, '/') - if not parts[2] then - o.title = vim.trim(parts[1]) - else - o.title = vim.trim(parts[2]) - o.dir = vim.trim(parts[1]) - end - - vim.lsp.buf_request(0, 'workspace/executeCommand', - { - command = 'zk.new', - arguments = { path, o }, - }, - function(_, _, result) - vim.lsp.util.jump_to_location{ - uri = vim.uri_from_fname(result.path), - range = {start={line=2, character=0}}, - } - vim.cmd('startinsert') - end - ) -end - -local function zk_index(path) - path = path or vim.loop.cwd() - vim.lsp.buf.execute_command { - command = 'zk.index', arguments = {path, nil}, - } -end - -return { - new = zk_new, - index = zk_index, -} |