diff options
| author | Robert Günzler <r@gnzler.io> | 2026-09-27 17:38:39 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2026-09-27 17:38:39 +0200 |
| commit | 0860db73ae6fd9a6f6347219d820bf026a6b8b91 (patch) | |
| tree | 11318c3670d1c32c5aa0bf404c22fba3bf63fc53 /.config/nvim/after/ftplugin | |
| parent | 4e34cbf9673aeaba252e01df554a0d204e83c5e2 (diff) | |
| download | dotfiles-0860db73ae6fd9a6f6347219d820bf026a6b8b91.tar.gz | |
Automated-commit-by: dots Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.config/nvim/after/ftplugin')
| -rw-r--r-- | .config/nvim/after/ftplugin/gitrebase.lua | 19 | ||||
| -rw-r--r-- | .config/nvim/after/ftplugin/go.lua | 32 | ||||
| -rw-r--r-- | .config/nvim/after/ftplugin/help.lua | 2 | ||||
| -rw-r--r-- | .config/nvim/after/ftplugin/janet.lua | 3 | ||||
| -rw-r--r-- | .config/nvim/after/ftplugin/markdown.lua | 9 | ||||
| -rw-r--r-- | .config/nvim/after/ftplugin/todotxt.lua | 13 | ||||
| -rw-r--r-- | .config/nvim/after/ftplugin/vala.lua | 1 |
7 files changed, 77 insertions, 2 deletions
diff --git a/.config/nvim/after/ftplugin/gitrebase.lua b/.config/nvim/after/ftplugin/gitrebase.lua index f85d3b9..fb64534 100644 --- a/.config/nvim/after/ftplugin/gitrebase.lua +++ b/.config/nvim/after/ftplugin/gitrebase.lua @@ -1,4 +1,19 @@ vim.keymap.set('n', 'K', function() - -- local cword = vim.fn.expand('<cword>') - -- require('gitsigns').show_commit(cword, 'aboveleft split') + local commit = vim.fn.expand('<cword>') + + local content = nil + require('mod.jobs').start({ + cmd = { 'git', 'show', '--patch', '--stat', commit }, + stdout_buffered = true, + on_stdout = function(_, stdout) + content = stdout + end, + on_exit = function() + require('mod.win').popup( + 'git-show: ' .. commit, + content, + { buf = { filetype = 'gitcommit' } } + ) + end, + }) end, { desc = 'Lookup commit hash', buffer = 0 }) diff --git a/.config/nvim/after/ftplugin/go.lua b/.config/nvim/after/ftplugin/go.lua new file mode 100644 index 0000000..ad5c56e --- /dev/null +++ b/.config/nvim/after/ftplugin/go.lua @@ -0,0 +1,32 @@ +vim.api.nvim_create_autocmd({ 'LspAttach' }, { + pattern = '*.go', + group = vim.api.nvim_create_augroup('lspattach.go', {}), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if not client:supports_method('workspace/executeCommand') then + return + end + + vim.keymap.set('n', '<leader>i', function() + local p = vim + .system({ + 'sh', + '-c', + [[go mod graph | awk '{print $2}' | cut -d@ -f1 | sort -u]], + }) + :wait() + local opts = vim.split(p.stdout, '\n') + vim.ui.select(opts, {}, function(choice) + client:exec_cmd({ + command = 'gopls.add_import', + arguments = { + { + ['ImportPath'] = choice, + ['URI'] = vim.uri_from_bufnr(0), + }, + }, + }) + end) + end, { desc = 'gopls: add import' }) + end, +}) diff --git a/.config/nvim/after/ftplugin/help.lua b/.config/nvim/after/ftplugin/help.lua new file mode 100644 index 0000000..f41256a --- /dev/null +++ b/.config/nvim/after/ftplugin/help.lua @@ -0,0 +1,2 @@ +-- open help in new tab +vim.cmd.wincmd "T" diff --git a/.config/nvim/after/ftplugin/janet.lua b/.config/nvim/after/ftplugin/janet.lua new file mode 100644 index 0000000..a81b2f0 --- /dev/null +++ b/.config/nvim/after/ftplugin/janet.lua @@ -0,0 +1,3 @@ +vim.o.expandtab = true +vim.o.shiftwidth = 2 +vim.o.commentstring = '# %s' diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua new file mode 100644 index 0000000..538a6da --- /dev/null +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -0,0 +1,9 @@ +vim.opt_local.makeprg = + 'pandoc -s -f markdown+wikilinks_title_after_pipe+autolink_bare_uris -t html -o /tmp/%.html %' + +vim.api.nvim_buf_create_user_command(0, 'OpenWeb', function() + local name = vim.fn.expand('%') + vim.system({ 'xdg-open', '/tmp/' .. name .. '.html' }) +end, { desc = 'markdown: open pdf' }) + +vim.keymap.set('n', '<leader>o', '<cmd>OpenWeb<cr>', { desc = 'markdown: open web', buffer = 0 }) diff --git a/.config/nvim/after/ftplugin/todotxt.lua b/.config/nvim/after/ftplugin/todotxt.lua index 526f29c..d5091b3 100644 --- a/.config/nvim/after/ftplugin/todotxt.lua +++ b/.config/nvim/after/ftplugin/todotxt.lua @@ -1 +1,14 @@ vim.opt_local.textwidth = 0 + +vim.keymap.set('n', '<m-x>', function() + require('mod.utils').edit_current_line(function(lines) + -- will only run for the current line + return vim.tbl_map(function(ln) + if string.sub(ln, 1, 2) == 'x ' then + return string.sub(ln, 3, -1) + else + return 'x ' .. ln + end + end, lines) + end) +end, { desc = 'Check todo', buffer = 0 }) diff --git a/.config/nvim/after/ftplugin/vala.lua b/.config/nvim/after/ftplugin/vala.lua new file mode 100644 index 0000000..3cbb257 --- /dev/null +++ b/.config/nvim/after/ftplugin/vala.lua @@ -0,0 +1 @@ +vim.o.commentstring = '// %s' |