neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim.git
Log | Files | Refs

commit 41e89bd1401292e7970f2715b2af90302543d8da
parent 9dce8f5aa93289eec48bdeaa8731229e054542d2
Author: Tomas Nemec <nemi@skaut.cz>
Date:   Tue,  4 Jan 2022 23:03:31 +0100

update

Diffstat:
Minit.lua | 4++--
Mlua/tms/lsp/init.lua | 17++++++++++++++---
Mlua/tms/p/aerial.lua | 20+++++++++++---------
Mlua/tms/p/luasnip.lua | 1+
Mlua/tms/p/nullls.lua | 2+-
Mlua/tms/p/telescope.lua | 1-
Alua/tms/p/zk.lua | 33+++++++++++++++++++++++++++++++++
Mlua/tms/plugins.lua | 9++++++++-
8 files changed, 70 insertions(+), 17 deletions(-)

diff --git a/init.lua b/init.lua @@ -1,9 +1,9 @@ local install_path = vim.fn.stdpath('data') .. '/site/pack/packer' -local packer_path = install_path..'/opt/packer.nvim' +local packer_path = install_path .. '/opt/packer.nvim' if vim.fn.empty(vim.fn.glob(packer_path)) > 0 then vim.api.nvim_command('!git clone --depth=1 https://github.com/wbthomason/packer.nvim ' .. packer_path) end -local impatient_path = install_path.. '/start/impatient.nvim' +local impatient_path = install_path .. '/start/impatient.nvim' if vim.fn.empty(vim.fn.glob(impatient_path)) > 0 then vim.api.nvim_command('!git clone --depth=1 https://github.com/lewis6991/impatient.nvim ' .. impatient_path) end diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua @@ -29,6 +29,12 @@ local on_attach = function(client, bufnr) local lsp = vim.lsp lsp.handlers['textDocument/hover'] = lsp.with(lsp.handlers.hover, {border = 'single'}) lsp.handlers['textDocument/signatureHelp'] = lsp.with(lsp.handlers.signature_help, {border = 'single'}) + if client.resolved_capabilities.goto_definition == true then + vim.api.nvim_buf_set_option(bufnr, 'tagfunc', 'v:lua.vim.lsp.tagfunc') + end + if client.resolved_capabilities.document_formatting == true then + vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr()') + end for _, cb in ipairs(attach_callbacks) do if cb.test(client, bufnr) then -- cb.fn(client, bufnr) @@ -46,13 +52,17 @@ local capabilities = function() end end -local add_server = function(name) - local lspc = require('lspconfig') +local server_opts = function(name) local opts = {} opts.on_attach = on_attach opts.capabilities = capabilities() opts = servers.setup(name, opts) - lspc[name].setup(opts) + return opts +end + +local add_server = function(name) + local opts = server_opts(name) + require('lspconfig')[name].setup(opts) end M.setup = function() @@ -80,6 +90,7 @@ M.setup = function() -- Manual install local manual_servers = {'gdscript', 'dartls'} for _, name in ipairs(manual_servers) do add_server(name) end + require('tms.p.zk').setup(server_opts('zk')) end M.add = function(name) add_server(name) end diff --git a/lua/tms/p/aerial.lua b/lua/tms/p/aerial.lua @@ -2,16 +2,18 @@ local M = {} M.setup = function() local aerial = require('aerial') - aerial.register_attach_cb(function(bufnr) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>r', '<cmd>AerialToggle!<CR>', {}) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '(', '<cmd>AerialPrev<CR>', {}) - vim.api.nvim_buf_set_keymap(bufnr, 'n', ')', '<cmd>AerialNext<CR>', {}) - -- vim.api.nvim_buf_set_keymap(bufnr, 'n', ']]', '<cmd>AerialPrevUp<CR>', {}) - -- vim.api.nvim_buf_set_keymap(bufnr, 'n', '[[', '<cmd>AerialNextUp<CR>', {}) - end) - + aerial.setup({}) require('telescope').load_extension('aerial') - require('tms.lsp').add_attach({fn = aerial.on_attach}) + require('tms.lsp').add_attach({ + fn = function(client, bufnr) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>r', '<cmd>AerialToggle!<CR>', {}) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', '(', '<cmd>AerialPrev<CR>', {}) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', ')', '<cmd>AerialNext<CR>', {}) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', ']]', '<cmd>AerialPrevUp<CR>', {}) + -- vim.api.nvim_buf_set_keymap(bufnr, 'n', '[[', '<cmd>AerialNextUp<CR>', {}) + aerial.on_attach(client, bufnr) + end, + }) end return M diff --git a/lua/tms/p/luasnip.lua b/lua/tms/p/luasnip.lua @@ -46,6 +46,7 @@ local snippets = function(luasnip) local fmt = require('luasnip.extras.fmt').fmt ls.snippets = { all = { + s('bang', t('#!/usr/bin/env ')), s('date', p(os.date, '%d.%m.%Y')), s('time', p(os.date, '%H:%M:%S')), s('todo', { diff --git a/lua/tms/p/nullls.lua b/lua/tms/p/nullls.lua @@ -38,7 +38,7 @@ M.setup = function() }), }, builtins.formatting.lua_format, - builtins.formatting.clang_format, + -- builtins.formatting.clang_format, builtins.formatting.shfmt.with { filetypes = {'sh', 'zsh'}, args = {'-i', vim.opt.shiftwidth:get(), '-filename', '$FILENAME'}, diff --git a/lua/tms/p/telescope.lua b/lua/tms/p/telescope.lua @@ -49,7 +49,6 @@ function M.setup() i = { -- ['<esc>'] = actions.close, - ['<c-r>'] = 'delete_buffer', ['<c-?>'] = action_generate.which_key({ name_width = 20, -- typically leads to smaller floats max_height = 0.5, -- increase potential maximum height diff --git a/lua/tms/p/zk.lua b/lua/tms/p/zk.lua @@ -0,0 +1,33 @@ +local M = {} + +local keybind = function() + vim.keymap.nnoremap {'<leader>zc', '<cmd>ZkNew<cr>'} + vim.keymap.xnoremap {'<leader>zc', '<cmd>ZkNewFromTitleSelection<cr>'} + vim.keymap.nnoremap {'<space>zn', '<cmd>ZkNotes<cr>'} + vim.keymap.nnoremap {'<space>zt', '<cmd>ZkTags<cr>'} + vim.keymap.nnoremap {'<space>zl', '<cmd>ZkLinks<cr>'} + vim.keymap.nnoremap {'<space>zo', '<cmd>ZkNotes {orphan = true}<cr>'} +end + +M.setup = function(lsp_cfg) + lsp_cfg = lsp_cfg or {} + require('zk').setup({lsp = {config = lsp_cfg}}) + require('telescope').load_extension('zk') + keybind() +end + +local make_lsp_location = function() + local params = vim.lsp.util.make_range_params() + params.uri = params.textDocument.uri + params.textDocument = nil + return params +end + +M.new_link = function() + vim.ui.input('title', function(title) + local location = make_lsp_location() + require('zk').new(nil, {insertLinkAtLocation = location, title = title}) + end) +end + +return M diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua @@ -207,6 +207,12 @@ return packer.startup({ requires = {'nvim-lua/plenary.nvim'}, config = function() require('tms.p.neorg').setup() end, } + use { + 'mickael-menu/zk-nvim', + requires = {'neovim/nvim-lspconfig'}, + after = {'telescope.nvim'}, + -- config = function() require('tms.p.zk').setup() end, + } -- quickfix list use {'kevinhwang91/nvim-bqf', config = function() require('tms.p.bqf').setup() end} @@ -217,7 +223,7 @@ return packer.startup({ 'folke/zen-mode.nvim', config = function() require('zen-mode').setup {} - vim.keymap.nnoremap {'<leader>z', '<cmd>ZenMode<cr>'} + vim.keymap.nnoremap {'<leader>Z', '<cmd>ZenMode<cr>'} end, } @@ -262,6 +268,7 @@ return packer.startup({ } use { -- git info for current line 'rhysd/git-messenger.vim', + setup = function() vim.g.git_messenger_floating_win_opts = {border = 'single'} end, config = function() vim.keymap.nnoremap {'<leader>gm', '<plug>(git-messenger)'} end, } use {