diff --git a/after/ftplugin/go.vim b/after/ftplugin/go.vim index d944013..f534ec2 100644 --- a/after/ftplugin/go.vim +++ b/after/ftplugin/go.vim @@ -1 +1,7 @@ set formatoptions+=r " auto add comments on line return + +" formatting with gofmt +" au BufEnter *.go set formatprg=gofmt\ -s +" au BufEnter *.go set formatprg=goimports +" +nnoremap fm :%!goimports diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 5f32322..e18ba05 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -12,6 +12,7 @@ M.general = { --{{{ ["jk"] = { "", "escape" }, + -- navigate within insert mode [""] = { "", "move left" }, [""] = { "", "move right" }, @@ -37,6 +38,10 @@ M.general = { --{{{ "no highlight" }, + -- smoth scrolling with M-j M-k + [""] = { "", "scroll down"}, + [""] = { "", "scroll down"}, + -- switch between windows [""] = { "h", "window left" }, [""] = { "l", "window right" }, @@ -267,6 +272,7 @@ M.general = { --{{{ ["g."] = { ":cwd", "change dir to current file", opts = { remap = true } }, ["g."] = { ":Gcd", "change dir to git root" }, + -- Packer commands -- -- PackerSnapshot @@ -277,7 +283,7 @@ M.general = { --{{{ end , "packer snapshot" }, ["pst"] = { " PackerStatus", "packer status" }, - ["psc"] = { " PackerSync", "packer sync" }, + -- ["psc"] = { " PackerSync", "packer sync" }, ["pc"] = { " PackerCompile", "packer compile" }, ["pr"] = { function() @@ -961,10 +967,11 @@ M.vimux = { } -- extra mappings for golang -M.golang = { +M.gonvim = { plugin = true, n = { - ["da"] = { " GoDebug -a", "go debug attach" }, + -- ["da"] = { " GoDebug -a", "go debug attach" }, + ["gotf"] = { " GoTestFunc" }, } } @@ -989,9 +996,12 @@ M.gitsigns = { "Git stage buffer", }, ["gR"] = { " lua require'gitsigns'.reset_buffer_index()", - "Git reset buffer index", + "Unstage all hunks for current buffer in the index", }, - ["gp"] = { " lua require'gitsigns'.preview_hunk()", + ["gr"] = { " lua require'gitsigns'.reset_buffer()", + "Reset the lines of all hunks in the buffer", + }, + ["gpr"] = { " lua require'gitsigns'.preview_hunk()", "Git preview hunk", }, ["gu"] = { " lua require'gitsigns'.undo_stage_hunk()", @@ -1009,18 +1019,19 @@ M.gitsigns = { M.grapple = { plugin = true, n = { - [",J"] = { " lua require'grapple'.cycle_forward()" }, - [",K"] = { " lua require'grapple'.cycle_backward()" }, - [",T"] = { " GrappleTag"}, - [",N"] = { function() + ["J"] = { " lua require'grapple'.cycle_forward()" }, + ["K"] = { " lua require'grapple'.cycle_backward()" }, + ["T"] = { " GrappleTag"}, + ["N"] = { function() vim.ui.input({ prompt = "tag: " }, function(input) - require("grapple").tag({ name = input }) + require("grapple").tag({ key = input }) end) end, "grapple tag with name" }, --TODO: keybind for popup select names - [",,m"] = { " lua require'grapple'.select({name='mappings'})" }, - [",,p"] = { " lua require'grapple'.select({name='plugins'})" }, - [",,P"] = { " lua require'grapple'.select({name='Plugins'})" }, + ["m"] = { " lua require'grapple'.select({key='mappings'})" }, + ["p"] = { " lua require'grapple'.select({key='plugins'})" }, + ["P"] = { " lua require'grapple'.select({key='Plugins'})" }, + ["g"] = { " lua require'grapple'.popup_tags()" }, } } @@ -1070,4 +1081,38 @@ M.zk = { } } +M.copilot = { + plugin = true, + n = { + -- copilot options here + } +} + +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' }, + } +} + +M.refactoring = { + plugin = true, + v = { + ["rr"] = {":lua require'refactoring'.select_refactor()", "refactoring using telescope", opts = { expr = false }}, + } +} + +M.null_ls = { + plugin = true, + n = { + ["nlr"] = {function() + require('null-ls').toggle({ + name = 'revive' + }) + end, "null-ls toggle golang linter "}, + } +} + return M diff --git a/lua/core/options.lua b/lua/core/options.lua index cec405e..9d492f6 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -169,7 +169,7 @@ end local default_providers = { "node", "perl", - "python3", + -- "python3", "ruby", } diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 3fca461..693a45f 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -16,7 +16,8 @@ local highlights = require "custom.highlights" -- vim.tbl_deep_extend("force", M.ui.hl_add, custom_theme) M.ui = { - theme = "gruvbox_material", + -- theme = "gruvbox_material", + theme = "ayu-dark", theme_toggle = { "gruvbox_material", "gruvbox_light" }, transparency = true, hl_override = highlights.override, diff --git a/lua/custom/highlights.lua b/lua/custom/highlights.lua index 41f4961..030e6b6 100644 --- a/lua/custom/highlights.lua +++ b/lua/custom/highlights.lua @@ -34,11 +34,14 @@ M.override = { St_LspInfo = { fg = "white" }, + LineNr = { + fg = "#5f4468" + }, } M.add = { Visual = { - bg = "blue", + bg = "#ff7775", fg = "black", }, BookmarkSign = { diff --git a/lua/custom/plugins/configs/chat-gpt.lua b/lua/custom/plugins/configs/chat-gpt.lua new file mode 100644 index 0000000..6b21b16 --- /dev/null +++ b/lua/custom/plugins/configs/chat-gpt.lua @@ -0,0 +1,91 @@ +local M = {} + +M.load_api_key = function() + local openai_api_key_path = vim.fn.expand('$XDG_CONFIG_HOME') .. '/openai/token' + local openai_api_key = vim.fn.readfile(openai_api_key_path, '', 1) + vim.fn.setenv('OPENAI_API_KEY', openai_api_key[1]) +end + + + +local config = { + -- welcome_message = WELCOME_MESSAGE, -- set to "" if you don't like the fancy godot robot + loading_text = "loading", + question_sign = "", -- you can use emoji if you want e.g. 🙂 + answer_sign = "ﮧ", -- 🤖 + max_line_length = 120, + yank_register = "+", + chat_layout = { + relative = "editor", + position = "50%", + size = { + height = "80%", + width = "80%", + }, + }, + settings_window = { + border = { + style = "rounded", + text = { + top = " Settings ", + }, + }, + }, + chat_window = { + filetype = "chatgpt", + border = { + highlight = "FloatBorder", + style = "rounded", + text = { + top = " ChatGPT ", + }, + }, + }, + chat_input = { + prompt = "  ", + border = { + highlight = "FloatBorder", + style = "rounded", + text = { + top_align = "center", + top = " Prompt ", + }, + }, + }, + openai_params = { + model = "text-davinci-003", + frequency_penalty = 0, + presence_penalty = 0, + max_tokens = 300, + temperature = 0, + top_p = 1, + n = 1, + }, + openai_edit_params = { + model = "code-davinci-edit-001", + temperature = 0, + top_p = 1, + n = 1, + }, + keymaps = { + close = { "", "" }, + yank_last = "", + scroll_up = "", + scroll_down = "", + toggle_settings = "", + new_session = "", + cycle_windows = "", + }, +} + +M.setup = function() + local ok, chatgpt = pcall(require, 'chatgpt') + if not ok then + vim.notify("missing module chatgpt", vim.log.levels.WARN) + return + end + chatgpt.setup(config) +end + + +return M diff --git a/lua/custom/plugins/configs/gonvim.lua b/lua/custom/plugins/configs/gonvim.lua index 8654d92..c39da20 100644 --- a/lua/custom/plugins/configs/gonvim.lua +++ b/lua/custom/plugins/configs/gonvim.lua @@ -1,3 +1,8 @@ +local ok, null_ls = pcall(require, 'null-ls') +if not ok then + vim.notify("missing module null-ls", vim.log.levels.WARN) +end + local M = {} local config = { @@ -11,10 +16,17 @@ local config = { lsp_codelens = false, -- use navigator textobjects = true, dap_debug_keymap = false, + -- dap_debug_gui = false, + -- dap_debug_vt = false, + log_path = vim.fn.stdpath('cache') .. '/gonvim.log', } function M.setup() - require("go").setup(config) + require("go").setup(config) + local gotest = require('go.null_ls').gotest() + local gotest_codeaction = require("go.null_ls").gotest_action() + null_ls.register(gotest) + null_ls.register(gotest_codeaction) end return M diff --git a/lua/custom/plugins/configs/grapple.lua b/lua/custom/plugins/configs/grapple.lua new file mode 100644 index 0000000..30a6061 --- /dev/null +++ b/lua/custom/plugins/configs/grapple.lua @@ -0,0 +1,22 @@ +local ok, grapple = pcall(require, 'grapple') +if not ok then + vim.notify("missing module grapple", vim.log.levels.WARN) + return +end + +local M = {} + +local config = { + -- Your configuration goes here + -- Leave empty to use the default configuration + -- Please see the Configuration section below for more information + scope = "git", + log_level = "warn", +} + +M.setup = function() + grapple.setup(config) +end + + +return M diff --git a/lua/custom/plugins/configs/lsp_signature.lua b/lua/custom/plugins/configs/lsp_signature.lua index e1f82b0..09a9a06 100644 --- a/lua/custom/plugins/configs/lsp_signature.lua +++ b/lua/custom/plugins/configs/lsp_signature.lua @@ -10,7 +10,7 @@ local config = { } -M = {} +local M = {} M.setup = function() signature.setup(config) end diff --git a/lua/custom/plugins/configs/luasnip.lua b/lua/custom/plugins/configs/luasnip.lua index be6aa8a..d7f0edf 100644 --- a/lua/custom/plugins/configs/luasnip.lua +++ b/lua/custom/plugins/configs/luasnip.lua @@ -4,6 +4,7 @@ if not present then return end +local M = {} local types = require("luasnip.util.types") local options = { diff --git a/lua/custom/plugins/configs/marks.lua b/lua/custom/plugins/configs/marks.lua index e68189e..0ca8240 100644 --- a/lua/custom/plugins/configs/marks.lua +++ b/lua/custom/plugins/configs/marks.lua @@ -5,7 +5,7 @@ if not present then end -M = {} +local M = {} local config = { bookmark_0 = { diff --git a/lua/custom/plugins/configs/navigator.lua b/lua/custom/plugins/configs/navigator.lua index 0e50432..301429d 100644 --- a/lua/custom/plugins/configs/navigator.lua +++ b/lua/custom/plugins/configs/navigator.lua @@ -27,9 +27,11 @@ local config = { { key = 'gd', func = require('navigator.definition').definition, desc = 'lsp definition' }, { key = 'gD', func = vim.lsp.buf.declaration, desc = 'lsp declaration' }, { key = 'gp', func = require('navigator.definition').definition_preview, desc = 'lsp definition_preview' }, - { key = 'gt', func = require('navigator.treesitter').buf_ts, desc = 'lsp buf_ts' }, - { key = 'gT', func = require('navigator.treesitter').bufs_ts, desc = 'lsp bufs_ts' }, - { key = 'ct', func = require('navigator.ctags').ctags, desc = 'lsp ctags' }, + -- handled by main mappings + -- { key = 'gt', func = require('navigator.treesitter').buf_ts, desc = 'lsp buf_ts' }, + -- { key = 'gT', func = require('navigator.treesitter').bufs_ts, desc = 'lsp bufs_ts' }, + -- { key = 'ct', func = require('navigator.ctags').ctags, desc = 'lsp ctags' }, + { key = 'K', func = vim.lsp.buf.hover, desc = 'lsp hover' }, { key = '', mode = 'n', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' }, { key = '', mode = 'i', func = require('navigator.codeAction').code_action, desc = 'lsp code_action' }, @@ -48,8 +50,8 @@ local config = { { key = 'D', func = vim.lsp.buf.type_definition, desc = 'lsp type_definition' }, { key = 'gL', func = require('navigator.diagnostics').show_diagnostics, desc = 'lsp show_diagnostics' }, { key = 'gG', func = require('navigator.diagnostics').show_buf_diagnostics, desc = 'lsp show_buf_diagnostics' }, - { key = 'dt', func = require('navigator.diagnostics').toggle_diagnostics, desc = 'lsp toggle_diagnostics' }, - { key = 'td', func = require('spike.diagnostics').toggle, desc = 'lsp toggle_diagnostics' }, + -- { key = 'dt', func = require('navigator.diagnostics').toggle_diagnostics, desc = 'lsp toggle_diagnostics' }, + -- { key = 'td', func = require('spike.diagnostics').toggle, desc = 'lsp toggle_diagnostics' }, { key = ']d', func = vim.diagnostic.goto_next, desc = 'lsp next diagnostics' }, { key = '[d', func = vim.diagnostic.goto_prev, desc = 'lsp prev diagnostics' }, { key = ']O', func = vim.diagnostic.set_loclist, desc = 'lsp diagnostics set loclist' }, @@ -144,7 +146,7 @@ local config = { }, diagnostic_scrollbar_sign = false, - display_diagnostic_qf = false, + disply_diagnostic_qf = false, disable_lsp = {"clangd", "rust_analyzer"}, @@ -169,18 +171,22 @@ local config = { } } }, + sumneko_lua = { + before_init=require("neodev.lsp").before_init, + } - ["neodev"] = { - library = { - enabled = true, - runtime = true, - -- plugins = true, - plugins = {"plenary.nvim"}, - -- plugins = {"navigator.lua", "guihua.lua", "go.nvim", "plenary.nvim"}, - types = true, - }, - setup_jsonls = true, - }, + -- FIX: deperecated https://github.com/ray-x/navigator.lua/commit/1b2a0856f4adfffc5c4e785a6779c62759c8c926 + -- ["neodev"] = { + -- library = { + -- enabled = true, + -- runtime = true, + -- -- plugins = true, + -- plugins = {"plenary.nvim"}, + -- -- plugins = {"navigator.lua", "guihua.lua", "go.nvim", "plenary.nvim"}, + -- types = true, + -- }, + -- setup_jsonls = true, + -- }, } } diff --git a/lua/custom/plugins/configs/neodev.lua b/lua/custom/plugins/configs/neodev.lua new file mode 100644 index 0000000..f0a7a52 --- /dev/null +++ b/lua/custom/plugins/configs/neodev.lua @@ -0,0 +1,45 @@ +local present, neodev = pcall(require, "neodev") + +if not present then + return +end + + +local M = {} + + +local config = { + library = { + enabled = true, -- when not enabled, neodev will not change any settings to the LSP server + -- these settings will be used for your Neovim config directory + runtime = true, -- runtime path + types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others + -- plugins = true, -- installed opt or start plugins in packpath + plugins = {"plenary.nvim"}, + -- -- plugins = {"navigator.lua", "guihua.lua", "go.nvim", "plenary.nvim"}, + -- you can also specify the list of plugins to make available as a workspace library + -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, + }, + setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files + -- for your Neovim config directory, the config.library settings will be used as is + -- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled + -- for any other directory, config.library.enabled will be set to false + -- override = function(root_dir, options) end, + + + -- NOTE: using navigator I have to include the custom before_init + -- With lspconfig, Neodev will automatically setup your lua-language-server + -- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init} + -- in your lsp start options + lspconfig = true, + -- much faster, but needs a recent built of lua-language-server + -- needs lua-language-server >= 3.6.0 + pathStrict = true, + +} + +M.setup = function() + neodev.setup(config) +end + +return M diff --git a/lua/custom/plugins/configs/null-ls.lua b/lua/custom/plugins/configs/null-ls.lua new file mode 100644 index 0000000..70d00f4 --- /dev/null +++ b/lua/custom/plugins/configs/null-ls.lua @@ -0,0 +1,47 @@ +local ok, null_ls = pcall(require, 'null-ls') +if not ok then + vim.notify("missing module null-ls", vim.log.levels.WARN) + return +end +local vim, api = vim, vim.api + +local M = {} +M.config = { + debounce = 1000, + default_timeout = 5000, + sources = { + null_ls.builtins.code_actions.gitsigns, + -- null_ls.builtins.diagnostics.golangci_lint, + + -- golang revive + null_ls.builtins.diagnostics.revive, + }, + on_attach = function(client, bufnr) + local util = require('navigator.util') + local log = util.log + local trace = util.trace + require('navigator.lspclient.highlight').add_highlight() + require('navigator.lspclient.highlight').diagnositc_config_sign() + api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + require('navigator.lspclient.mapping').setup({ + client = client, + bufnr = bufnr, + }) + if client.server_capabilities.documentHighlightProvider == true then + trace('attaching doc highlight: ', bufnr, client.name) + vim.defer_fn(function() + require('navigator.dochighlight').documentHighlight(bufnr) + end, 50) -- allow a bit time for it to settle down + else + log('skip doc highlight: ', bufnr, client.name) + end + require('navigator.lspclient.lspkind').init() + end +} + +M.setup = function() + null_ls.setup(M.config) +end + + +return M diff --git a/lua/custom/plugins/configs/refactoring.lua b/lua/custom/plugins/configs/refactoring.lua new file mode 100644 index 0000000..4e26b61 --- /dev/null +++ b/lua/custom/plugins/configs/refactoring.lua @@ -0,0 +1,34 @@ +local ok, refactoring = pcall(require, 'refactoring') +if not ok then + vim.notify("missing module refactoring", vim.log.levels.WARN) + return +end + +local M = {} + + +local config = { +-- prompt for return type + prompt_func_return_type = { + go = true, + cpp = true, + c = true, + java = true, + }, + -- prompt for function parameters + prompt_func_param_type = { + go = true, + cpp = true, + c = true, + java = true, + }, +} + +M.setup = function() + refactoring.setup(config) + -- require("telescope").load_extension("refactoring") +end + + + +return M diff --git a/lua/custom/plugins/configs/todo-comments.lua b/lua/custom/plugins/configs/todo-comments.lua index 1944f4e..efcfe36 100644 --- a/lua/custom/plugins/configs/todo-comments.lua +++ b/lua/custom/plugins/configs/todo-comments.lua @@ -4,7 +4,7 @@ if not present then return end -M = {} +local M = {} local config = { keywords = { @@ -25,7 +25,7 @@ local config = { }, highlight = { -- multiline = false, - after = "fg", + after = "", } } diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 14a4bac..9fef051 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -114,6 +114,58 @@ return { end }, -- }}} + ["hrsh7th/cmp-copilot"] = { + after = "copilot.vim" + }, + + + -- Code Refactoring + ["ThePrimeagen/refactoring.nvim"] = { + setup = function() + require("core.utils").load_mappings "refactoring" + end, + config = function() + require("custom.plugins.configs.refactoring").setup() + end, + after = {"telescope.nvim"}, + requires = { + {"nvim-lua/pleanery.nvim"}, + {"nvim-treesitter/nvim-treesitter"} + } + }, + + -- AI/Deep Learning Helpers + -- Github Copilot + ["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.*"} + }, + + ["jackMort/ChatGPT.nvim"] = { + opt = true, + keys = {"gpt"}, + module_pattern = {"chatgpt*"}, + after = {"nui.nvim", "telescope.nvim"}, + setup = function() + require("custom.plugins.configs.chat-gpt").load_api_key() + end, + config = function() + require("custom.plugins.configs.chat-gpt").setup() + end, + requires = { + "MunifTanjim/nui.nvim", + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim" + } + }, + -- snippets ["honza/vim-snippets"] = { -- {{{ module = { "cmp", "cmp_nvim_lsp" }, @@ -156,7 +208,7 @@ return { ["folke/todo-comments.nvim"] = { -- {{{ -- commit = "6124066", - after = "nvim-treesitter", + -- after = "nvim-treesitter", setup = function() -- require("core.lazy_load").on_file_open "todo-comments" require("core.utils").load_mappings "todo-comments" @@ -176,7 +228,7 @@ return { -- ["p00f/nvim-ts-rainbow"] = { -- opt = true, -- }, - -- + -- dap @@ -193,7 +245,8 @@ return { }, ["rcarriga/nvim-dap-ui"] = { - tag = "*", + -- tag = "*", + commit = "1e21b3b", after = "nvim-dap", config = function() require('custom.plugins.configs.dapui').setup() @@ -248,6 +301,15 @@ return { keys = { "", "", "", "\"", "`", "'", "z", "g" } }, + + -- scren saver + ["folke/drop.nvim"] = { + opt = true, + config = function() + require("drop").setup() + end + }, + -- repeat operator for plugin commands ["tpope/vim-repeat"] = { keys = { "." }, @@ -278,7 +340,7 @@ return { ["ibhagwan/fzf-lua"] = { lock = true, after = "ui", - config = function() + eonfig = function() require("custom.plugins.configs.fzflua") require("plugins.configs.others").devicons() end, @@ -289,7 +351,7 @@ return { -- Theme customization ["uga-rosa/ccc.nvim"] = { -- {{{{{{ - commit = "427471b", + -- commit = "427471b", cmd = { "Ccc*", "(ccc-insert)" }, setup = function() require("core.utils").load_mappings "ccc" @@ -313,20 +375,12 @@ return { }, -- }}} ["cbochs/grapple.nvim"] = { - commit = "50b8271", + -- commit = "50b8271", setup = function() require("core.utils").load_mappings "grapple" end, config = function() - require("grapple").setup({ - -- Your configuration goes here - -- Leave empty to use the default configuration - -- Please see the Configuration section below for more information - save_path = vim.fn.stdpath("data") .. "/" .. "grapple.json", - scope = "global", - log_level = "debug", - - }) + require('custom.plugins.configs.grapple').setup() end }, -- tmux helpers @@ -459,6 +513,7 @@ return { "terminal*", "db*", "aerial*", + "grapple", }, }) end @@ -496,7 +551,7 @@ return { -- ------------------ ["neovim/nvim-lspconfig"] = { -- {{{ - after = { "neodev.nvim", "mason.nvim", "mason-lspconfig.nvim" }, + after = {"mason.nvim", "mason-lspconfig.nvim", "neodev.nvim" }, module = { "lspconfig" }, lock = false, config = function() @@ -531,15 +586,15 @@ return { lock = false, opt = true, module = "navigator", - after = { "nvim-lspconfig", "base46", "ui", "mason.nvim", "mason-lspconfig.nvim", "neodev.nvim" }, + after = { "nvim-lspconfig", "base46", "ui", "mason.nvim", "mason-lspconfig.nvim", "neodev.nvim", "null-ls.nvim"}, requires = { "neovim/nvim-lspconfig", "ray-x/guihua.lua", "nvim-treesitter/nvim-treesitter" }, setup = function() require("core.lazy_load").on_file_open "navigator.lua" - -- require("core.utils").load_mappings "navigator" end, config = function() require("custom.plugins.configs.navigator").setup() require("base46").load_highlight "lsp" + require("core.utils").load_mappings "navigator" -- TODO: use nvchadui_lsp features manually -- require("nvchad_ui.lsp") @@ -555,6 +610,16 @@ return { }, -- }}} + ["jose-elias-alvarez/null-ls.nvim"] = { + requires = {"nvim-lua/plenary.nvim"}, + setup = function() + require('core.utils').load_mappings 'null_ls' + end, + config = function() + require("custom.plugins.configs.null-ls").setup() + end, + }, + -- side panel with symbols (replaced by Navigator :LspSymbols cmd) -- ["liuchengxu/vista.vim"] = { -- cmd = "Vista", @@ -650,6 +715,11 @@ return { ["folke/neodev.nvim"] = { -- commit = "d6212c1" -- module = "neodev", + ft = {'lua'}, + module = {'neodev'}, + config = function() + require('custom.plugins.configs.neodev').setup() + end }, ["hrsh7th/cmp-nvim-lua"] = { -- NOTE: needs to be disabled for neodev disable = true, @@ -658,12 +728,13 @@ return { -- golang dev ["ray-x/go.nvim"] = { -- {{{ - lock = true, -- after = {"nvim-lspconfig", "navigator.lua", "guihua.lua"}, ft = { "go" }, opt = true, + after = {"null-ls.nvim"}, config = function() require("custom.plugins.configs.gonvim").setup() + require("core.utils").load_mappings "gonvim" end }, -- }}} @@ -698,7 +769,7 @@ return { -- https://github.com/kristijanhusak/vim-dadbod-ui ["tpope/vim-dadbod"] = { ft = "sql", - cmd = {"DBUI"}, + cmd = {"DBUI"}, }, ["kristijanhusak/vim-dadbod-ui"] = { after = {"vim-dadbod"}, @@ -715,9 +786,17 @@ return { end }, + -- Python + ["dccsillag/magma-nvim"] = { + opt = true, + run = ':UpdateRemotePlugins', + }, + -- theseraus{{{ -- ["Ron89/thesaurus_query.vim"] = { }, -- setup in after/plugin/vim-lexical + -- requires a thesearus file like from here: + -- https://www.gutenberg.org/files/3202/files/ ["preservim/vim-lexical"] = { },-- }}} } diff --git a/lua/custom/plugins/nvchadui.lua b/lua/custom/plugins/nvchadui.lua index cd82a2b..bb21bee 100644 --- a/lua/custom/plugins/nvchadui.lua +++ b/lua/custom/plugins/nvchadui.lua @@ -107,6 +107,11 @@ return { local Lsp = vim.lsp.util.get_progress_messages()[1] + -- hide spammy null-ls progress + if Lsp and Lsp.name:match "null%-ls" then + return "" + end + if vim.o.columns < 120 or not Lsp then return "" end diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index b411af4..065bace 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -161,6 +161,7 @@ local options = { }, { name = "nvim_lua", priority = 900 }, { name = "path" }, + { name = "copilot" }, }, } diff --git a/lua/spike/dap/dapmode.lua b/lua/spike/dap/dapmode.lua index 8dd131b..c785361 100644 --- a/lua/spike/dap/dapmode.lua +++ b/lua/spike/dap/dapmode.lua @@ -1,7 +1,7 @@ local libmodal = require 'libmodal' local daputils = require 'spike.dap.utils' -M = {} +local M = {} M.layer = nil diff --git a/lua/spike/lsp/go.lua b/lua/spike/lsp/go.lua index ecad6f4..ec82862 100644 --- a/lua/spike/lsp/go.lua +++ b/lua/spike/lsp/go.lua @@ -27,7 +27,7 @@ function M.gopls_onattach(client, bufnr) -- end -- }) - require("core.utils").load_mappings "golang" + -- require("core.utils").load_mappings "golang" end diff --git a/lua/spike/utils/init.lua b/lua/spike/utils/init.lua index dfc1e95..ac6dc73 100644 --- a/lua/spike/utils/init.lua +++ b/lua/spike/utils/init.lua @@ -44,4 +44,26 @@ end end end +-- convert timestamp under cursor in milliseconds to a human readable string +-- @param timestamp in milliseconds +-- @return human readable string +M.human_timestamp = function() + cword = vim.fn.expand('') + + + -- make sure cword is a number + local n = tonumber(cword) + if n == nil then return end + + local time = os.date("*t", cword / (1000*1000)) + format = string.format("%04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day, time.hour, time.min, time.sec) + vim.notify(format, vim.lsp.log_levels.INFO) +end + +-- 1663878015759000 +-- 1670185951498000 +-- M.human_timestamp() + return M + + diff --git a/notes/Tips.md b/notes/Tips.md index c16c3b2..61141d5 100644 --- a/notes/Tips.md +++ b/notes/Tips.md @@ -36,3 +36,23 @@ a line break is inserted before the appended text. like from a scheduled func call or timer, save the var in vim.g and access it as global variable + +# Refactoring +* [refactoring article](https://alpha2phi.medium.com/neovim-for-beginners-refactoring-4f517d12a43f) +:argdo — Execute the command for each file in the argument list +:bufdo — Execute the command in each buffer in the buffer list +:tabdo — Execute the command in each tab page +:windo — Execute the command in each window +:cdo — Execute the command in each valid entry in the quickfix list (entry itself not the file) +:cfdo — Execute the command in each file in the quickfix list +:vimgrep `:vimgrep // ##` where ## is replaces with files in arg list + +## Filtering quickfix +`packadd cfilter` +`:Cfilter /pattern/` +`:Lfilter /pattern` + +## Delete lines matching pattern +!! Use the :global command + + :g/profile/d