From 33aa97c9e0395e9aeef5d4229a94aefa76c449ef Mon Sep 17 00:00:00 2001 From: blob42 Date: Sun, 12 Mar 2023 14:00:16 +0100 Subject: [PATCH] updates --- after/plugin/diagnostics.lua | 2 +- lua/core/mappings.lua | 46 +++++++--------- lua/custom/chadrc.lua | 3 +- lua/custom/plugins/configs/copilot.lua | 58 +++++++++++++++++++++ lua/custom/plugins/configs/live-command.lua | 2 +- lua/custom/plugins/configs/rust-tools.lua | 17 +++--- lua/custom/plugins/init.lua | 32 +++++++++--- mysnippets/all.lua | 3 +- mysnippets/lua.lua | 10 ++-- mysnippets/python.lua | 25 +++++++++ 10 files changed, 150 insertions(+), 48 deletions(-) create mode 100644 lua/custom/plugins/configs/copilot.lua create mode 100644 mysnippets/python.lua diff --git a/after/plugin/diagnostics.lua b/after/plugin/diagnostics.lua index b1ccf64..e243108 100644 --- a/after/plugin/diagnostics.lua +++ b/after/plugin/diagnostics.lua @@ -1 +1 @@ -require 'spike.diagnostics'.set_diagnostics_level(vim.diagnostic.severity.WARN) +require 'spike.diagnostics'.set_diagnostics_level(vim.diagnostic.severity.ERROR) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 82bf68a..b078060 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -84,6 +84,9 @@ M.general = { --{{{ -- Just in case you need to go to the very beginning of a line ["^"] = { "0" }, + -- delete all empty lines + [""] = { " .,/\\S\\|\\%$/g/^\\s*$/d noh", "delete empty next contiguous empty lines" }, + ["ww"] = { " set wrap! echo 'wrap = '.&wrap " }, @@ -218,6 +221,7 @@ M.general = { --{{{ ["tf"] = { " set foldmethod=expr| set foldexpr=nvim_treesitter#foldexpr()", "enable Treesitter folding" }, + ["tp"] = { function() vim.cmd("TSPlaygroundToggle") @@ -927,7 +931,7 @@ M.iron = { -- {{{{{{ M.ccc = { plugin = true, n = { - ["cp"] = { "CccPick", "color picker" } + ["clp"] = { "CccPick", "color picker" } }, } -- }}} @@ -1006,44 +1010,32 @@ 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 = { ["J"] = { " lua require'grapple'.cycle_forward()" }, ["K"] = { " lua require'grapple'.cycle_backward()" }, ["T"] = { " GrappleTag"}, + ["GT"] = { function() + vim.ui.input({ prompt = "tag: " }, function(input) + require("grapple").tag({scope="global"}) + end) + end, "grapple global tag" }, ["N"] = { function() vim.ui.input({ prompt = "tag: " }, function(input) 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) + require("grapple").tag({scope="global", key = input}) end) end, "grapple global tag with name" }, --TODO: keybind for popup select names -- ["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 }, + ["m"] = { " lua require'grapple'.select {key='mappings', scope='global'}" }, + ["p"] = { " lua require'grapple'.select {key='plugins', scope='global'}" }, + ["b"] = { " lua require'grapple'.select {key='bonzai', scope='global'}" }, ["P"] = { " lua require'grapple'.select({key='Plugins'})" }, ["o"] = { " lua require'grapple'.select({key='options'})" }, ["g"] = { " lua require'grapple'.popup_tags()" }, @@ -1101,15 +1093,18 @@ M.copilot = { plugin = true, n = { -- copilot options here + ["cpn"] = { " lua require'copilot.panel'.open()", "copilot panel" }, + ["]p"] = { " lua require'copilot.panel'.jump_next() ", "copilot panel next" }, + ["[p"] = { " lua require'copilot.panel'.jump_prev() ", "copilot panel prev" }, } } M.navigator = { plugin = true, n = { - ["gt"] = { function() require('navigator.treesitter').buf_ts() end, 'TS buf symbols'}, - ["gT"] = { function() require('navigator.treesitter').bufs_ts() end, 'TS bufs symbols'}, - ['ct'] = { function() require('navigator.ctags').ctags() end, 'lsp ctags' }, + ["gt"] = { function() require("navigator.treesitter").buf_ts() end, "TS buf symbols"}, + ["gT"] = { function() require("navigator.treesitter").bufs_ts() end, "TS bufs symbols"}, + ["ct"] = { function() require("navigator.ctags").ctags() end, "lsp ctags" }, } } @@ -1137,5 +1132,4 @@ M.null_ls = { } } - return M diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 693a45f..4d4803b 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -17,7 +17,8 @@ local highlights = require "custom.highlights" M.ui = { -- theme = "gruvbox_material", - theme = "ayu-dark", + -- theme = "ayu-dark", + theme = "catppuccin", theme_toggle = { "gruvbox_material", "gruvbox_light" }, transparency = true, hl_override = highlights.override, diff --git a/lua/custom/plugins/configs/copilot.lua b/lua/custom/plugins/configs/copilot.lua new file mode 100644 index 0000000..d761f3d --- /dev/null +++ b/lua/custom/plugins/configs/copilot.lua @@ -0,0 +1,58 @@ +local ok, copilot = pcall(require, 'copilot') +if not ok then + vim.notify("missing module copilot", vim.log.levels.WARN) + return +end + +local M = {} + +local config = { + panel = { + enabled = true, + auto_refresh = false, + keymap = { + jump_prev = "[[", + jump_next = "]]", + accept = "", + refresh = "gr", + open = "" + }, + layout = { + position = "bottom", -- | top | left | right + ratio = 0.4 + }, + }, + suggestion = { + enabled = true, + auto_trigger = false, + debounce = 75, + keymap = { + accept = "", + accept_word = false, + accept_line = false, + next = "", + prev = "", + dismiss = "", + }, + }, + filetypes = { + yaml = false, + markdown = false, + help = false, + gitcommit = false, + gitrebase = false, + hgcommit = false, + svn = false, + cvs = false, + ["."] = false, + }, + copilot_node_command = 'node', -- Node.js version must be > 16.x + server_opts_overrides = {}, +} + +M.setup = function() + copilot.setup(config) +end + +return M + diff --git a/lua/custom/plugins/configs/live-command.lua b/lua/custom/plugins/configs/live-command.lua index 7d8f9b6..3a0ab6a 100644 --- a/lua/custom/plugins/configs/live-command.lua +++ b/lua/custom/plugins/configs/live-command.lua @@ -12,7 +12,7 @@ local opts = { }, }, - debug = true, + debug = false, commands = { Norm = { cmd = "norm" }, Reg = { diff --git a/lua/custom/plugins/configs/rust-tools.lua b/lua/custom/plugins/configs/rust-tools.lua index eae24c0..749c0f9 100644 --- a/lua/custom/plugins/configs/rust-tools.lua +++ b/lua/custom/plugins/configs/rust-tools.lua @@ -167,12 +167,17 @@ local opts = { -- debugging stuff dap = { - adapter = { - type = "executable", - command = "lldb-vscode", - name = "rt_lldb", - console = "integratedTerminal", - }, + -- adapter = { + -- type = "executable", + -- command = "lldb-vscode", + -- -- command = "/home/spike/.local/share/nvim/mason/bin/codelldb", + -- name = "rt_lldb", + -- console = "integratedTerminal", + -- }, + adapter = require('rust-tools.dap').get_codelldb_adapter( + "/home/spike/.local/share/nvim/mason/packages/codelldb/extension/adapter/codelldb", + "/home/spike/.local/share/nvim/mason/packages/codelldb/extension/lldb/lib/liblldb.so" + ) }, } diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 729c349..8ee7fbc 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -119,8 +119,11 @@ return { end }, -- }}} - ["hrsh7th/cmp-copilot"] = { - after = "copilot.vim" + ["zbirenbaum/copilot-cmp"] = { + after = {"copilot.lua"}, + config = function() + require("copilot_cmp").setup() + end }, @@ -141,13 +144,27 @@ return { -- AI/Deep Learning Helpers -- Github Copilot - ["github/copilot.vim"] = { + + ["zbirenbaum/copilot.lua"] = { opt = true, + cmd = "Copilot", keys = {"ghp"}, - setup= function() + setup = function() require("core.utils").load_mappings "copilot" - end + end, + config = function() + require("custom.plugins.configs.copilot").setup() + end, }, + + -- ["github/copilot.vim"] = { + -- opt = true, + -- keys = {"ghp"}, + -- setup= function() + -- require("core.utils").load_mappings "copilot" + -- end + -- }, + ["MunifTanjim/nui.nvim"] = { module = {"nui.layout", "nui.popup"}, module_pattern = {"nui.*"} @@ -348,6 +365,7 @@ return { }, -- }}} -- Theme customization + -- Color picker ["uga-rosa/ccc.nvim"] = { -- {{{{{{ -- commit = "427471b", cmd = { "Ccc*", "(ccc-insert)" }, @@ -743,7 +761,7 @@ return { -- Rust dev ["simrat39/rust-tools.nvim"] = { -- {{{ - lock = true, + lock = false, ft = { "rust" }, opt = true, config = function() @@ -806,7 +824,7 @@ return { -- jupyter notebook -- dependencies: jupyter jupytext ["luk400/vim-jukit"] = { - lock = true, + lock = false, keys = 'jup', setup = function() patterns = { diff --git a/mysnippets/all.lua b/mysnippets/all.lua index fe9fc88..fe875e1 100644 --- a/mysnippets/all.lua +++ b/mysnippets/all.lua @@ -21,7 +21,8 @@ return { -- function node s("pwd", f(function() return vim.fn.getcwd() - end)) + end)), + }, { --autosnippets -- s("uuid#", f(gen_uuid)) } diff --git a/mysnippets/lua.lua b/mysnippets/lua.lua index 006d13d..99b9eb9 100644 --- a/mysnippets/lua.lua +++ b/mysnippets/lua.lua @@ -15,14 +15,14 @@ return M -- repeat nodes -- TODO: split dot and pull last name -- local require - s("lreq", fmt("local {} = require('{}')", { + s("lreq", fmt("local {} = require(\"{}\")", { i(1, "default"), rep(1) }) ), -- if require s("ifreq", fmt([[ - local ok, {} = pcall(require, '{}') + local ok, {} = pcall(require, "{}") if not ok then vim.notify("missing module {}", vim.log.levels.WARN) return @@ -38,12 +38,12 @@ return M ), -- add a custom mapping - s({ trig = 'map', dscr = 'add custom mapping'}, fmt([[ - ['{}'] = {{ {}, '{}' }}, + s({ trig = "map", dscr = "add custom mapping"}, fmt([[ + ["{}"] = {{ {}, "{}" }}, ]], { i(1, 'from'), c(3, { - sn(nil, fmt([['{}']], {i(1)})), + sn(nil, fmt([["{}"]], {i(1)})), sn(nil, fmt([[function() {} end]], {i(1)})), sn(nil, fmt([[{}]], {i(1)})), }), diff --git a/mysnippets/python.lua b/mysnippets/python.lua new file mode 100644 index 0000000..09789fd --- /dev/null +++ b/mysnippets/python.lua @@ -0,0 +1,25 @@ +return { + -- AGPL3 + s("AGPL3", fmt([[ + # The AGPLv3 License (AGPLv3) + # + # Copyright (c) 2023 {} + # + # {} is free software: you can redistribute it and/or modify + # it under the terms of the GNU Affero General Public License as + # published by the Free Software Foundation, either version 3 of the + # License, or (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU Affero General Public License for more details. + # + # You should have received a copy of the GNU Affero General Public License + # along with this program. If not, see . + ]], { + i(1), i(0) + })) +}, { --autosnippets + -- s("uuid#", f(gen_uuid)) +}