From 5216048827f124a4b6fa525f324ed332c605a67c Mon Sep 17 00:00:00 2001 From: blob42 Date: Wed, 22 Feb 2023 19:50:20 +0100 Subject: [PATCH] updates --- lua/core/mappings.lua | 65 +++++++++++++++++++++-- lua/core/options.lua | 4 +- lua/custom/plugins/configs/dap.lua | 31 +++++++++++ lua/custom/plugins/configs/dapui.lua | 2 + lua/custom/plugins/configs/navigator.lua | 66 ++++++++++++++++++++---- lua/custom/plugins/configs/neodev.lua | 2 +- lua/custom/plugins/init.lua | 59 +++++++++++---------- lua/spike/nullls.lua | 2 - mysnippets/all.lua | 9 ++++ plugin/spike/abbrev.vim | 1 + plugin/spike/commands.vim | 6 +++ 11 files changed, 201 insertions(+), 46 deletions(-) create mode 100644 plugin/spike/abbrev.vim diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 3f4dedc..82bf68a 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -1,4 +1,4 @@ --- vim: foldmethod=marker foldlevel=1 + -- n, v, i, t, c = mode name.s local function termcodes(str) @@ -336,9 +336,34 @@ M.general = { --{{{ -- ["lsp"] = { " lua require('custom.plugins.configs.navigator').enable()", "lsp enable"}, ["lsp"] = { " LspStart", "lsp enable" }, [""] = { " LspStart", "lsp enable" }, - [""] = { " LspStop", "lsp disable" }, + [""] = {function() + local bufnr = vim.api.nvim_get_current_buf() + -- get all clients for buffer + local clients = vim.lsp.get_active_clients({ + bufnr = bufnr + }) + + if #clients > 1 then + -- select clients to turn off + vim.ui.select(clients, { + prompt = 'Stop LSP Clients', + format_item = function (item) + return item.name + end + }, function(item) + if item then vim.lsp.stop_client(item.id) end + end) + elseif #clients == 1 then + vim.lsp.stop_client(clients[1].id) + else + return + end + + end, "lsp disable" }, ["lst"] = { " LspStop", "lsp disable" }, + -- My custom commands + ["gB"] = {" GitBlob"}, --------------- @@ -381,6 +406,7 @@ M.general = { --{{{ -- Change Working Directory to that of the current file ["cwd"] = { "lcd %:p:h", "change dir to current file" }, ["cd."] = { "lcd %:p:h", "change dir to current file" }, + ["cdv"] = { "lcd ~/.config/nvim", "change to vim directory" }, ["w!!"] = { "w !doas tee %", "write file with root perms" }, ["%%"] = { "=fnameescape(expand('%:h')).'/'", "alias to current working dir" }, @@ -784,6 +810,10 @@ M.nvterm = { --{{{ nvterm_utils.run_cmd(nil, { mode = "vertical" }) end, "run cmd in vertical terminal"}, + ["rh"] = {function() + local nvterm_utils = require('spike.utils.nvterm') + nvterm_utils.run_cmd(nil, { mode = "horizontal" }) + end, "run cmd in horizontal terminal"}, [""] = {function() local nvterm_utils = require('spike.utils.nvterm') @@ -975,6 +1005,23 @@ M.gitsigns = { } } + +-- selects a grapple key given a scope and resets +-- the `git` scope +local function grapple_scope_select(scope, key) + local grapple = require("grapple") + grapple.setup({scope = scope }) + grapple.select({key=key}) + grapple.setup({scope = "git"}) +end + +local function grapple_scope_tag(scope, key) + local grapple = require("grapple") + grapple.setup({scope = scope}) + grapple.tag({key=key}) + grapple.setup({scope = "git"}) +end + M.grapple = { plugin = true, n = { @@ -986,11 +1033,21 @@ M.grapple = { require("grapple").tag({ key = input }) end) end, "grapple tag with name" }, + ["GN"] = { function() + local grapple = require("grapple") + vim.ui.input({ prompt = "tag: " }, function(input) + grapple_scope_tag("global", input) + end) + end, "grapple global tag with name" }, --TODO: keybind for popup select names - ["m"] = { " lua require'grapple'.select({key='mappings'})" }, - ["p"] = { " lua require'grapple'.select({key='plugins'})" }, + -- ["m"] = { " lua require'grapple'.scope_select('global', 'mappings')" }, + ["m"] = { function() grapple_scope_select("global", "mappings") end}, + ["p"] = { function() grapple_scope_select("global", "plugins") end }, + ["b"] = { function() grapple_scope_select("global", "bonzai") end }, ["P"] = { " lua require'grapple'.select({key='Plugins'})" }, + ["o"] = { " lua require'grapple'.select({key='options'})" }, ["g"] = { " lua require'grapple'.popup_tags()" }, + ["G"] = { " lua require'grapple'.popup_tags('global')" }, } } diff --git a/lua/core/options.lua b/lua/core/options.lua index 9d492f6..69c10e6 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -26,7 +26,9 @@ opt.showmode = false opt.title = true opt.clipboard = "unnamed" opt.cul = true -- cursor line -opt.colorcolumn = "80" +-- opt.colorcolumn = "80" +opt.colorcolumn = '+0' -- make colorcolumn follow text width +opt.textwidth = 80 opt.rulerformat = "%30(%=:b%n%y%m%r%w %l,%c%V %P%)" -- NvChad has custom ruler ! -- Indenting diff --git a/lua/custom/plugins/configs/dap.lua b/lua/custom/plugins/configs/dap.lua index d8b8b74..fecb97d 100644 --- a/lua/custom/plugins/configs/dap.lua +++ b/lua/custom/plugins/configs/dap.lua @@ -5,6 +5,37 @@ local opts = { } +-- config for dap ui virt text +local dap_ui_virt_text_config = { + enabled = true, -- enable this plugin (the default) + enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) + highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText + highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) + show_stop_reason = true, -- show stop reason when stopped for exceptions + commented = false, -- prefix virtual text with comment string + only_first_definition = true, -- only show virtual text at first definition (if there are multiple) + all_references = false, -- show virtual text on all all references of the variable (not only definitions) + filter_references_pattern = ' custom.configs.treesitter + lock = true, setup = function() require("core.lazy_load").on_file_open "nvim-treesitter" require("core.lazy_load").on_file_open "nvim-treesitter-textobjects" @@ -66,6 +67,7 @@ return { end, }, ["nvim-treesitter/nvim-treesitter-textobjects"] = { + lock = true, opt = true, }, -- ["RRethy/nvim-treesitter-textsubjects"] = { @@ -73,6 +75,7 @@ return { -- }, ["ziontee113/syntax-tree-surfer"] = { + lock = true, opt = true, config = function() require("syntax-tree-surfer").setup() @@ -80,11 +83,13 @@ return { }, -- Treesitter dev/exploration tool ["nvim-treesitter/playground"] = { + lock = true, opt = true, cmd = { "TSPlayground*" }, }, ["nvim-treesitter/nvim-treesitter-context"] = { + lock = true, opt = true, config = function() require("custom.plugins.configs.treesitter-context").setup() @@ -129,7 +134,7 @@ return { end, after = {"telescope.nvim"}, requires = { - {"nvim-lua/pleanery.nvim"}, + {"nvim-lua/plenary.nvim"}, {"nvim-treesitter/nvim-treesitter"} } }, @@ -149,6 +154,7 @@ return { }, ["jackMort/ChatGPT.nvim"] = { + -- lock = true, opt = true, keys = {"gpt"}, module_pattern = {"chatgpt*"}, @@ -207,6 +213,7 @@ return { }, ["folke/todo-comments.nvim"] = { -- {{{ + lock = true, -- commit = "6124066", -- after = "nvim-treesitter", setup = function() @@ -220,8 +227,10 @@ return { ["tpope/vim-surround"] = {}, + ["tpope/vim-abolish"] = {}, + ["godlygeek/tabular"] = { - lcmd = "Tabularize" + cmd = {"Tabularize"} }, -- }}} @@ -246,6 +255,7 @@ return { ["rcarriga/nvim-dap-ui"] = { -- tag = "*", + lock = true, commit = "1e21b3b", after = "nvim-dap", config = function() @@ -255,30 +265,17 @@ return { ["theHamsta/nvim-dap-virtual-text"] = { lock = true, - after = "nvim-dap", + -- opt = true, + after = {"nvim-dap"}, config = function() - require("nvim-dap-virtual-text").setup({ - enabled = true, -- enable this plugin (the default) - enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) - highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText - highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) - show_stop_reason = true, -- show stop reason when stopped for exceptions - commented = false, -- prefix virtual text with comment string - only_first_definition = true, -- only show virtual text at first definition (if there are multiple) - all_references = false, -- show virtual text on all all references of the variable (not only definitions) - filter_references_pattern = '" }, cmd = { "Aerial*" }, @@ -714,6 +714,7 @@ return { -- neodev (replaces lua-dev) ["folke/neodev.nvim"] = { + lock = true, -- commit = "d6212c1" -- module = "neodev", ft = {'lua'}, @@ -729,6 +730,7 @@ return { -- golang dev ["ray-x/go.nvim"] = { -- {{{ + lock = true, -- after = {"nvim-lspconfig", "navigator.lua", "guihua.lua"}, ft = { "go" }, opt = true, @@ -779,6 +781,7 @@ return { -- zk nvim ["mickael-menu/zk-nvim"] = { + lock = true, setup = function() require("core.utils").load_mappings "zk" end, @@ -801,7 +804,9 @@ return { -- }, -- jupyter notebook + -- dependencies: jupyter jupytext ["luk400/vim-jukit"] = { + lock = true, keys = 'jup', setup = function() patterns = { diff --git a/lua/spike/nullls.lua b/lua/spike/nullls.lua index 2dc4b5e..b938872 100644 --- a/lua/spike/nullls.lua +++ b/lua/spike/nullls.lua @@ -16,13 +16,11 @@ M.select_sources = function() vim.ui.select(sources, { prompt = "select source to toggle:", format_item = function (item) - P(item) local enabled = item._disabled local entry = item._disabled and '' or '' local filetypes = '' for ft, _ in pairs(item.filetypes) do - P(ft) filetypes = filetypes .. ft .. '|' end filetypes = filetypes:gsub('|$', '') diff --git a/mysnippets/all.lua b/mysnippets/all.lua index 42bb3d7..fe9fc88 100644 --- a/mysnippets/all.lua +++ b/mysnippets/all.lua @@ -1,4 +1,9 @@ ---@diagnostic disable: undefined-global +-- +-- TODO!: how to cleanly exec system processes (fn.execute vs os.execute vs jobstart) +-- local function gen_uuid(args, parent) +-- t = os.execute("uuidgen") +-- end return { -- s("sniptest", { @@ -17,4 +22,8 @@ return { s("pwd", f(function() return vim.fn.getcwd() end)) +}, { --autosnippets + -- s("uuid#", f(gen_uuid)) } + +-- diff --git a/plugin/spike/abbrev.vim b/plugin/spike/abbrev.vim new file mode 100644 index 0000000..5671b4b --- /dev/null +++ b/plugin/spike/abbrev.vim @@ -0,0 +1 @@ +iabbrev .-  diff --git a/plugin/spike/commands.vim b/plugin/spike/commands.vim index a7dff91..57db899 100644 --- a/plugin/spike/commands.vim +++ b/plugin/spike/commands.vim @@ -9,3 +9,9 @@ command! -bang WA wa command! -bang Q q command! -bang QA qa command! -bang Qa qa + +" preview markdown in browser +command! -bang MDPreview silent !md2html --github % | pipe-to-browser + +" migrate git config to blob42 +command! -bang GitBlob42 %S/sp4ke.{xyz,com}/blob42.xyz/ge|%S/sp4ke/blob42/ge