From 7fbdbf0203b38efbd47796cd162b1f13b8e07315 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 1 Nov 2022 15:56:23 +0100 Subject: [PATCH] nvim: Update formatting --- nvim/.config/nvim/init.lua | 11 ++++--- nvim/.config/nvim/lua/plug/_autopair.lua | 8 ++--- nvim/.config/nvim/lua/plug/_cmp.lua | 32 +++++++++---------- nvim/.config/nvim/lua/plug/_gitsigns.lua | 40 ++++++++++++++++++++++++ nvim/.config/nvim/lua/plugins.lua | 20 ++++++------ nvim/.config/nvim/plugin/vim-pandoc.vim | 4 +-- 6 files changed, 78 insertions(+), 37 deletions(-) create mode 100644 nvim/.config/nvim/lua/plug/_gitsigns.lua diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index ad79d2c..1047d06 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -11,15 +11,18 @@ require('maps') vim.api.nvim_create_autocmd({ "TextYankPost" }, { command = 'silent! lua require"vim.highlight".on_yank{timeout=500}', desc = "Highlight yanked text whenevery yanking something", - group = vim.api.nvim_create_augroup('highlightyanks', { clear = true }), + group = vim.api.nvim_create_augroup('highlightyanks', { clear = true }) }) -- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { - pattern = { "/dev/shm/gopass.*", "/dev/shm/pass.?*/?*.txt", "$TMPDIR/pass.?*/?*.txt", "/tmp/pass.?*/?*.txt" }, + pattern = { + "/dev/shm/gopass.*", "/dev/shm/pass.?*/?*.txt", + "$TMPDIR/pass.?*/?*.txt", "/tmp/pass.?*/?*.txt" + }, command = 'setlocal noswapfile nobackup noundofile nowritebackup viminfo=', desc = "Don't leak any information when editing potential password files", - group = vim.api.nvim_create_augroup('passnoleak', { clear = true }), + group = vim.api.nvim_create_augroup('passnoleak', { clear = true }) }) api.nvim_exec('runtime abbrev.vim', false) @@ -31,5 +34,5 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, { vim.defer_fn(function() vim.loop.kill(pid, WINCH) end, 20) end, desc = "Fix neovim sizing issues if opening same time as alacritty", - group = vim.api.nvim_create_augroup('alacritty_fixsize', { clear = true }), + group = vim.api.nvim_create_augroup('alacritty_fixsize', { clear = true }) }) diff --git a/nvim/.config/nvim/lua/plug/_autopair.lua b/nvim/.config/nvim/lua/plug/_autopair.lua index a2ad8a1..85f756d 100644 --- a/nvim/.config/nvim/lua/plug/_autopair.lua +++ b/nvim/.config/nvim/lua/plug/_autopair.lua @@ -1,4 +1,4 @@ -require('nvim-autopairs').setup({check_ts = true}) +require('nvim-autopairs').setup({ check_ts = true }) --- Auto-space rules local npairs = require 'nvim-autopairs' @@ -7,12 +7,10 @@ local Rule = require 'nvim-autopairs.rule' npairs.add_rules { Rule(' ', ' '):with_pair(function(opts) local pair = opts.line:sub(opts.col, opts.col + 1) - return vim.tbl_contains({'()', '[]', '{}'}, pair) + return vim.tbl_contains({ '()', '[]', '{}' }, pair) end) } local cmp_autopairs = require('nvim-autopairs.completion.cmp') local cmp = require('cmp') cmp.event:on('confirm_done', - cmp_autopairs.on_confirm_done({map_char = {tex = ''}})) --- add a lisp filetype (wrap my-function), FYI: Hardcoded = { "clojure", "clojurescript", "fennel", "janet" } -cmp_autopairs.lisp[#cmp_autopairs.lisp + 1] = "racket" + cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) diff --git a/nvim/.config/nvim/lua/plug/_cmp.lua b/nvim/.config/nvim/lua/plug/_cmp.lua index b4c0329..23b72b1 100644 --- a/nvim/.config/nvim/lua/plug/_cmp.lua +++ b/nvim/.config/nvim/lua/plug/_cmp.lua @@ -4,29 +4,29 @@ local lspkind = require 'lspkind' local has_words_before = function() local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and - vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, - col) - :match("%s") == nil + vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, + col) + :match("%s") == nil end local feedkey = function(key, mode) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), - mode, true) + mode, true) end vim.o.completeopt = "menu,menuone,noselect" -- completion items require('cmp').register_source('vCard', require('completion_vcard').setup_cmp( - '~/documents/contacts/myconts')) + '~/documents/contacts/myconts')) vim.g.vsnip_snippet_dir = (vim.env.XDG_DATA_HOME or "~/.local/share") .. - "/nvim/snippets" + "/nvim/snippets" cmp.setup({ - snippet = {expand = function(args) vim.fn["vsnip#anonymous"](args.body) end}, + snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end }, mapping = { - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}), - [''] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}), + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. [''] = cmp.mapping({ i = cmp.mapping.abort(), @@ -34,7 +34,7 @@ cmp.setup({ }), -- Accept currently selected item. If none selected, `select` first item. -- Set `select` to `false` to only confirm explicitly selected items. - [''] = cmp.mapping.confirm({select = false}), + [''] = cmp.mapping.confirm({ select = false }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -45,7 +45,7 @@ cmp.setup({ else fallback() end - end, {"i", "s"}), + end, { "i", "s" }), [""] = cmp.mapping(function() if cmp.visible() then @@ -53,7 +53,7 @@ cmp.setup({ elseif vim.fn["vsnip#jumpable"](-1) == 1 then feedkey("(vsnip-jump-prev)", "") end - end, {"i", "s"}) + end, { "i", "s" }) }, formatting = { format = lspkind.cmp_format({ @@ -80,18 +80,18 @@ require 'cmp_pandoc'.setup{ } if vim.o.ft == 'clap_input' and vim.o.ft == 'guihua' and vim.o.ft == - 'guihua_rust' then require'cmp'.setup.buffer {completion = {enable = false}} end + 'guihua_rust' then require 'cmp'.setup.buffer { completion = { enable = false } } end -- Use buffer source for `/` search cmp.setup.cmdline('/', { mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({{name = 'buffer'}}) + sources = cmp.config.sources({ { name = 'buffer' } }) }) -- Use cmdline & path source for ':' in vim cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}}) + sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) }) require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol diff --git a/nvim/.config/nvim/lua/plug/_gitsigns.lua b/nvim/.config/nvim/lua/plug/_gitsigns.lua new file mode 100644 index 0000000..378a12b --- /dev/null +++ b/nvim/.config/nvim/lua/plug/_gitsigns.lua @@ -0,0 +1,40 @@ +-- require('gitsigns').setup { +-- on_attach = function(bufnr) +-- local gs = package.loaded.gitsigns +-- +-- local function map(mode, l, r, opts) +-- opts = opts or {} +-- opts.buffer = bufnr +-- vim.keymap.set(mode, l, r, opts) +-- end +-- +-- -- Navigation +-- map('n', ']h', function() +-- if vim.wo.diff then return ']h' end +-- vim.schedule(function() gs.next_hunk() end) +-- return '' +-- end, {expr = true}) +-- +-- map('n', '[h', function() +-- if vim.wo.diff then return '[h' end +-- vim.schedule(function() gs.prev_hunk() end) +-- return '' +-- end, {expr = true}) +-- +-- -- Actions +-- map({'n', 'v'}, 'hs', ':Gitsigns stage_hunk') +-- map('n', 'hS', gs.stage_buffer) +-- map({'n', 'v'}, 'hr', ':Gitsigns reset_hunk') +-- map('n', 'hR', gs.reset_buffer) +-- map('n', 'hu', gs.undo_stage_hunk) +-- map('n', 'hp', gs.preview_hunk) +-- map('n', 'hb', function() gs.blame_line {full = true} end) +-- map('n', 'hB', gs.toggle_current_line_blame) +-- map('n', 'hd', gs.diffthis) +-- map('n', 'hD', function() gs.diffthis('~') end) +-- map('n', 'hdd', gs.toggle_deleted) +-- +-- -- Text object +-- map({'o', 'x'}, 'ih', ':Gitsigns select_hunk') +-- end +-- } diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index a9048da..abab70a 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -2,15 +2,15 @@ local install_path = vim.fn.stdpath("data") .. "/pack/packer/start/packer.nvim" if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. - install_path) + install_path) end -- Compile on plugin edits -vim.api.nvim_create_autocmd({ "BufWritePost" }, { +vim.api.nvim_create_autocmd({"BufWritePost"}, { pattern = "plugins.lua", command = "PackerCompile", desc = "Compile plugins after editing plugin list", - group = vim.api.nvim_create_augroup('compilepackages', { clear = true }) + group = vim.api.nvim_create_augroup('compilepackages', {clear = true}) }) local use = require("packer").use @@ -34,11 +34,7 @@ require("packer").startup(function() 'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter requires = {'nvim-lua/plenary.nvim'}, tag = 'release', - config = function() - require('gitsigns').setup { - keymaps = {['n ]c'] = nil, ['n [c'] = nil} - } - end, + config = function() require('plug._gitsigns') end, event = "BufRead" } use { @@ -213,11 +209,15 @@ require("packer").startup(function() -- lsp use 'neovim/nvim-lspconfig' -- some commong language server configurations - use 'simrat39/symbols-outline.nvim' -- vista-like outline view for code + use { + 'simrat39/symbols-outline.nvim', + config = function() require('symbols-outline').setup() end + } -- vista-like outline view for code use 'ray-x/lsp_signature.nvim' use { 'ray-x/navigator.lua', - requires = {'ray-x/guihua.lua', run = 'cd lua/fzy && make'} + requires = {'ray-x/guihua.lua', run = 'cd lua/fzy && make'}, + config = function() require('plug._lsp') end } -- and completion use { diff --git a/nvim/.config/nvim/plugin/vim-pandoc.vim b/nvim/.config/nvim/plugin/vim-pandoc.vim index d662324..8387248 100644 --- a/nvim/.config/nvim/plugin/vim-pandoc.vim +++ b/nvim/.config/nvim/plugin/vim-pandoc.vim @@ -1,8 +1,8 @@ " PLUGIN: vim-pandoc " handle markdown files with pandoc (and pandoc syntax!) let g:pandoc#modules#disabled = [ "keyboard", "folding" ] -let g:pandoc#filetypes#pandoc_markdown = 1 -let g:pandoc#filetypes#handled = [ "extra", "latex", "markdown", "pandoc", "rst", "textile" ] +let g:pandoc#filetypes#pandoc_markdown = 0 +let g:pandoc#filetypes#handled = [ "extra", "latex", "markdown", "pandoc", "rst", "textile"] " disable all default keymaps let g:pandoc#keyboard#use_default_mappings=0 " needs to be set for wrapping and unwrapping of lines to work when doing j/k