From 333e2580f078661526523a94d0ca9f7f981eb683 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 15 Dec 2021 17:38:10 +0100 Subject: [PATCH 1/3] git: Add personal git server substitutions Added automatic aliasing for my own git server pushing and pulling. --- git/.config/git/config | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git/.config/git/config b/git/.config/git/config index 0672470..4697b86 100644 --- a/git/.config/git/config +++ b/git/.config/git/config @@ -45,6 +45,11 @@ [url "git@gitlab.com:"] pushInsteadOf = "https://gitlab.com" pushInsteadOf = "http://gitlab.com" +[url "git@git.martyoeh.me:"] + pushInsteadOf = "https://git.martyoeh.me" + pushInsteadOf = "http://git.martyoeh.me" + pushInsteadOf = "git@martyoeh.me" + pullInsteadOf = "git@martyoeh.me" [filter "lfs"] clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f From e64df2ec3deb7e8b2dd2ae85a46b49088310c1f0 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 15 Dec 2021 10:31:11 +0100 Subject: [PATCH 2/3] nvim: Switch deprecated nvim-compe Switched out the deprecated nvim-compe for nvim-cmp and re-added most of the plugins that the earlier one supported. The handling is very similar and it supports the same snippet engine (vsnip in this case). --- nvim/.config/nvim/lua/plug/_autopair.lua | 10 +- .../nvim/lua/plug/_indent-blankline.lua | 7 +- nvim/.config/nvim/lua/plug/_lsp.lua | 118 +++++++++++++----- nvim/.config/nvim/lua/plugins.lua | 29 +++-- 4 files changed, 118 insertions(+), 46 deletions(-) diff --git a/nvim/.config/nvim/lua/plug/_autopair.lua b/nvim/.config/nvim/lua/plug/_autopair.lua index 6781edd..a2ad8a1 100644 --- a/nvim/.config/nvim/lua/plug/_autopair.lua +++ b/nvim/.config/nvim/lua/plug/_autopair.lua @@ -1,8 +1,4 @@ require('nvim-autopairs').setup({check_ts = true}) -require("nvim-autopairs.completion.compe").setup({ - map_cr = true, -- map on insert mode - map_complete = true -- it will auto insert `(` after select function or method item -}) --- Auto-space rules local npairs = require 'nvim-autopairs' @@ -14,3 +10,9 @@ npairs.add_rules { 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" diff --git a/nvim/.config/nvim/lua/plug/_indent-blankline.lua b/nvim/.config/nvim/lua/plug/_indent-blankline.lua index 3aebee3..5927df3 100644 --- a/nvim/.config/nvim/lua/plug/_indent-blankline.lua +++ b/nvim/.config/nvim/lua/plug/_indent-blankline.lua @@ -1,14 +1,11 @@ -- Settings for indentBlankline -- turn off for diff views since we want to compare directly -if vim.wo.diff then - vim.g["indent_blankline_enabled"] = false -end +if vim.wo.diff then vim.g["indent_blankline_enabled"] = false end vim.g.indent_blankline_char = "▏" vim.g.indent_blankline_filetype_exclude = { - "help", "undotree", - "markdown", "text", "pandoc", "rst", "asciidoc", + "help", "undotree", "markdown", "text", "pandoc", "rst", "asciidoc", "vim-plug" } vim.g.indent_blankline_buftype_exclude = {"terminal"} diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua index febfe7a..f2a9f72 100644 --- a/nvim/.config/nvim/lua/plug/_lsp.lua +++ b/nvim/.config/nvim/lua/plug/_lsp.lua @@ -2,7 +2,23 @@ local api = vim.api local saga = require 'lspsaga' local lspcfg = require 'lspconfig' -local compe = require 'compe' +local cmp = require 'cmp' +local lspkind = require 'lspkind' + +require"lsp_signature".setup() + +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 +end + +local feedkey = function(key, mode) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), + mode, true) +end -- Enable the following language servers local servers = { @@ -10,35 +26,77 @@ local servers = { -- sumneko_lua further down, needs more setup } -vim.o.completeopt = "menuone,noselect" --- completion sources, higher priority = closer to the top? -compe.setup({ - source = { - nvim_lsp = {kind = ""}, - nvim_treesitter = {kind = "⧻"}, - buffer = {kind = ""}, - path = {kind = ""}, - calc = {kind = ""}, - nvim_lua = true, - emoji = { - kind = "ﲃ", - filetypes = {"markdown", "text", "pandoc", "rst", "asciidoc"} - }, - latex_symbols = { - kind = "λ", - filetypes = {"markdown", "text", "pandoc", "rst", "asciidoc"} - }, - tmux = {kind = "τ"}, - spell = {kind = "", priority = 0}, - vsnip = true - } +vim.o.completeopt = "menu,menuone,noselect" + +-- completion items +require('cmp').register_source('vCard', require('completion_vcard').setup_cmp( + '~/documents/contacts/myconts')) +vim.g.vsnip_snippet_dir = (vim.env.XDG_DATA_HOME or "~/.local/share") .. + "/nvim/snippets" +cmp.setup({ + 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.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close() + }), + -- 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(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, {"i", "s"}), + + [""] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#jumpable"](-1) == 1 then + feedkey("(vsnip-jump-prev)", "") + end + end, {"i", "s"}) + }, + formatting = { + format = lspkind.cmp_format({ + with_text = false, + menu = ({ + buffer = "B", + nvim_lua = "NLua", + tmux = "τ", + vCard = "VCARD" + }) + }) + }, + sources = cmp.config.sources({ + {name = 'path'}, {name = 'nvim_lsp'}, {name = 'treesitter'}, + {name = 'tmux'}, {name = 'vsnip'}, {name = 'latex_symbols'}, + {name = 'pandoc_references'}, {name = 'vCard'} + }, {{name = 'buffer'}, {name = 'spell'}}) }) -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true -capabilities.textDocument.completion.completionItem.resolveSupport = { - properties = {'documentation', 'detail', 'additionalTextEdits'} -} +-- Use buffer source for `/` search +cmp.setup.cmdline('/', {sources = {{name = 'buffer'}}}) + +-- Use cmdline & path source for ':' in vim +cmp.setup.cmdline(':', { + sources = cmp.config.sources({{name = 'path'}}, {{name = 'cmdline'}}) +}) + +-- Setup lspconfig. +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp + .protocol + .make_client_capabilities()) local on_attach = function(_, _) -- Keybindings for LSPs @@ -109,7 +167,9 @@ local on_attach = function(_, _) end -- set up simple servers -for _, lsp in ipairs(servers) do lspcfg[lsp].setup {on_attach = on_attach} end +for _, lsp in ipairs(servers) do + lspcfg[lsp].setup {on_attach = on_attach, capabilities = capabilities} +end lspcfg.efm.setup { on_attach = on_attach, diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index b4ea19f..c375374 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -26,9 +26,10 @@ require("packer").startup(function() use 'jeffkreeftmeijer/vim-numbertoggle' -- toggles numbers to absolute for all buffers but the current which is relative use 'RRethy/vim-illuminate' -- highlight other occurences of the word under cursor use 'ggandor/lightspeed.nvim' -- jump between letters with improved fFtT quicksearch, mimics sneak - use 'lukas-reineke/indent-blankline.nvim' -- show a vertical line for each indentation - require('plug._indent-blankline') - + -- use { -- weird errors currently + -- 'lukas-reineke/indent-blankline.nvim', -- show a vertical line for each indentation + -- config = function() require('plug._indent-blankline') end + -- } -- files use 'vifm/vifm.vim' -- integrate file manager use { @@ -125,7 +126,6 @@ require("packer").startup(function() -- -- nvim plugs - use 'Iron-E/nvim-cartographer' -- makes it easier to set mappings through lua use 'marty-oehme/zettelkasten.nvim' -- simple static markdown linking use { @@ -145,12 +145,21 @@ require("packer").startup(function() -- lsp use 'neovim/nvim-lspconfig' -- some commong language server configurations - use 'tami5/lspsaga.nvim' -- nice and fast ui for lsp actions + use 'tami5/lspsaga.nvim' -- nice and fast ui for lsp actions WILL HAVE TO BE REPLACED SOON use 'simrat39/symbols-outline.nvim' -- vista-like outline view for code + use 'ray-x/lsp_signature.nvim' -- and completion - use 'hrsh7th/nvim-compe' -- simple completion engine built specifically for nvim and lsp - use 'GoldsteinE/compe-latex-symbols' -- adding unicode symbols for latex (/pandoc) files - use {'andersevenrud/compe-tmux', branch = 'compe' } -- completion source from adjacent tmux panes + use { + 'hrsh7th/nvim-cmp', -- simple completion engine built specifically for nvim and lsp + requires = { + 'onsails/lspkind-nvim', 'andersevenrud/cmp-tmux', -- completion source from adjacent tmux panes + 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-vsnip', + 'kdheepak/cmp-latex-symbols', 'ray-x/cmp-treesitter', + 'f3fora/cmp-spell', 'jc-doyle/cmp-pandoc-references', + 'cbarrete/completion-vcard' + } + } -- snippeting use {"hrsh7th/vim-vsnip", event = "InsertEnter"} -- snippet engine use {"rafamadriz/friendly-snippets", event = "InsertEnter"} -- many snippets @@ -181,5 +190,9 @@ require("packer").startup(function() } use 'p00f/nvim-ts-rainbow' -- rainbow brackets using treesitter use 'JoosepAlviste/nvim-ts-context-commentstring' -- improves commenting plugin above by using ts + use { + 'lewis6991/spellsitter.nvim', -- uses treesitter to highlight spelling errors + config = function() require('spellsitter').setup() end + } end) From 981c4cbf10998a0899f5b8b89b0034bd9150691b Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 15 Dec 2021 17:28:45 +0100 Subject: [PATCH 3/3] Add vim-slime and vim-ipython-cell Added interactive python repl commands with two plugins: Sending repl snippets over with vim-slime and interacting with python (notebook-like) snippets in the editor with vim-ipython-cell. Cells are simply demarcated by `## ` at the beginning of a line, though they can have other syntaxes as well, e.g. `# %% `. By default slime sends its commands over to the last used tmux pane so it is easy to set up a split coding/repl-ing session. Interaction mappings all center around c + another key. You can send a simple cell with `cc` or `C`, single lines or selections with `cs`. You can switch between cells with `]c` `[c` and insert new ones below/above existing ones with `co` `cO` respectively. --- nvim/.config/nvim/lua/maps.lua | 29 +++++++++++++++++++++++------ nvim/.config/nvim/lua/plugins.lua | 26 +++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/maps.lua index 3196360..f0e8278 100644 --- a/nvim/.config/nvim/lua/maps.lua +++ b/nvim/.config/nvim/lua/maps.lua @@ -71,16 +71,14 @@ map.n.nore[']a'] = ':next' map.n.nore['[b'] = ':bprevious' map.n.nore[']b'] = ':bnext' -- Quickfix list -map.n.nore['[c'] = ':cprevious' -map.n.nore[']c'] = ':cnext' +map.n.nore['[q'] = ':cprevious' +map.n.nore[']q'] = ':cnext' -- Location list map.n.nore['[l'] = ':lprevious' map.n.nore[']l'] = ':lnext' -- Hunks (from gitsigns) -map.n.nore.expr['[h'] = - [[&diff ? ']c' : 'lua require("gitsigns.actions").prev_hunk()']] -map.n.nore.expr[']h'] = - [[&diff ? '[c' : 'lua require("gitsigns.actions").next_hunk()']] +map.n.nore.expr['[h'] = [[&diff ? ']c' : 'Gitsigns prev_hunk']] +map.n.nore.expr[']h'] = [[&diff ? '[c' : 'Gitsigns next_hunk']] -- set our leader key to space since with hjkl, space is largely useless vim.g.mapleader = " " @@ -257,3 +255,22 @@ map.n.nore['ww'] = [[:lua require 'zettelkasten'.open_index() ]] -- PLUGIN: toggleterm.nvim -- create a lazygit window, set up in toggleterm settings map.n.nore['G'] = ':Lazygit' + +-- PLUGIN: slime and ipython-cell +-- send line / region, not adhering to cells +map.n['cs'] = 'SlimeLineSend' +map.x['cs'] = 'SlimeRegionSend' +-- send complete script to repl / benchmark execution +map.n.nore['cr'] = ':IPythonCellRun' +map.n.nore['cR'] = ':IPythonCellRunTime' +-- send current cell / send and go to next +map.n.nore['cc'] = ':IPythonCellExecuteCellVerbose' +map.n.nore['C'] = ':IPythonCellExecuteCellVerboseJump' +-- clear ipython repl +map.n.nore['cl'] = ':IPythonCellClear' +-- jump to previous/ next cell +map.n.nore[']c'] = ':IPythonCellNextCell' +map.n.nore['[c'] = ':IPythonCellPrevCell' +-- insert cell header above/below +map.n.nore['cO'] = ':IPythonCellInsertAbovea' +map.n.nore['co'] = ':IPythonCellInsertBelowa' diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index c375374..de16ac9 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -36,7 +36,12 @@ 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() end, + config = function() require('gitsigns').setup{ + keymaps = { + ['n ]c'] = nil, + ['n [c'] = nil, + } + } end, event = "BufRead" } use { @@ -124,6 +129,25 @@ require("packer").startup(function() -- languages use {'euclidianAce/BetterLua.vim', ft = 'lua'} -- better syntax highlighting for lua + -- REPL work + use { + 'jpalardy/vim-slime', -- send arbitrary code chunks to REPLs + ft = "python", + config = function() + vim.g.slime_target = 'tmux' + vim.g.slime_default_config = {socket_name = "default", target_pane = "{last}"} + vim.g.slime_python_ipython = 1 + vim.g.slime_no_mappings = 1 + end, + } + use { 'hanschen/vim-ipython-cell', -- send code 'cells' to REPL + ft = "python", + config = function() + vim.g.ipython_cell_highlight_cells_ft = {'python'} + vim.g.ipython_cell_insert_tag = "## Cell" + end, + } + -- -- nvim plugs use 'Iron-E/nvim-cartographer' -- makes it easier to set mappings through lua