summary refs log tree commit diff
path: root/.vim/lua
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-02-23 13:25:59 +0100
committerRobert Günzler <r@gnzler.io>2021-04-26 02:09:44 +0200
commitaf429ed47696cc62ae29759524fca49a791e845d (patch)
treee5f2e6e6d29620277b8ddde9a4b6bcfdd517b521 /.vim/lua
parent01c7c7a51b65a836d7d33c9320a80a0537cff6e1 (diff)
vim: update 2021-02-23T13:26:28Z+01:00
Diffstat (limited to '.vim/lua')
-rw-r--r--.vim/lua/plugins.lua2
-rw-r--r--.vim/lua/plugins/_lsp.lua19
-rw-r--r--.vim/lua/utils.lua10
3 files changed, 21 insertions, 10 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua
index 4830b4b..6ec9e61 100644
--- a/.vim/lua/plugins.lua
+++ b/.vim/lua/plugins.lua
@@ -43,7 +43,7 @@ return require'packer'.startup(function()
 	use {'cohama/lexima.vim'}      -- auto-close parens, brackets, etc.
 	use {'tpope/vim-surround'}     -- edit surroundings in pairs
 	-- use {'neomake/neomake'}        -- async job runner
-	-- use {'sbdchd/neoformat'}       -- async code formatter
+	use {'sbdchd/neoformat'}       -- async code formatter
 	use {'justinmk/vim-dirvish'}   -- folder browser
 	use {'justinmk/vim-sneak',
 		config = "vim.g['sneak#label'] = true"
diff --git a/.vim/lua/plugins/_lsp.lua b/.vim/lua/plugins/_lsp.lua
index 9d98aca..780f703 100644
--- a/.vim/lua/plugins/_lsp.lua
+++ b/.vim/lua/plugins/_lsp.lua
@@ -1,8 +1,9 @@
 -- lsp config
 
-local lsp     = require('lspconfig')
-local util    = require('lspconfig.util')
-local u       = require('utils')
+local lsp      = require('lspconfig')
+local util     = require('lspconfig.util')
+local u        = require('utils')
+local nnoremap = require('astronauta.keymap').nnoremap
 
 -- https://github.com/kosayoda/nvim-lightbulb
 require('nvim-lightbulb').update_lightbulb {
@@ -22,12 +23,12 @@ local my_attach = function(client)
 	require 'completion'.on_attach(client)
 
 	-- lsp mappings
-	u.map('n', 'K',     '<cmd>lua vim.lsp.buf.hover()<cr>')
-	u.map(0, 'n', '<c-]>', '<cmd>lua vim.lsp.buf.definition()<cr>')
-	u.map(0, 'n', 'grr',   '<cmd>lua vim.lsp.buf.rename()<cr>')
-	u.map(0, 'i', '<c-h>', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
-	u.map(0, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>')
-	u.map(0, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>')
+	nnoremap { 'K', function() vim.lsp.buf.hover() end }
+	nnoremap { '<C-]>', function() vim.lsp.buf.definition() end }
+	nnoremap { 'grr',   function() vim.lsp.buf.rename() end }
+	nnoremap { '<c-h>', function() vim.lsp.buf.signature_help() end }
+	nnoremap { ']d', function() vim.lsp.diagnostic.goto_next() end }
+	nnoremap { '[d', function() vim.lsp.diagnostic.goto_prev() end }
 
 	-- nnoremap <silent> gD <cmd> lua vim.lsp.buf.declaration()<CR>
 	-- nnoremap <silent> gd <cmd> lua vim.lsp.buf.definition()<CR>
diff --git a/.vim/lua/utils.lua b/.vim/lua/utils.lua
index ab7793f..271d593 100644
--- a/.vim/lua/utils.lua
+++ b/.vim/lua/utils.lua
@@ -26,6 +26,16 @@ M.augroup = function(name, autocmds)
 	end
 	vim.cmd('augroup END')
 end
+M.augroup2 = function(tbl)
+	for name, autocmds in pairs(tbl) do
+		vim.cmd('augroup ' .. name)
+		vim.cmd('autocmd!')
+		for _, au in ipairs(autocmds) do
+			vim.cmd('autocmd ' .. table.concat(au, ' '))
+		end
+		vim.cmd('augroup END')
+	end
+end
 
 M.def = function(name, cmd, ...)
 	local opts = table.concat((... or {}), ' ')