From 62f9d0c757969d61def3b4c76bc39cb1ed9d172e Mon Sep 17 00:00:00 2001 From: Solomon Laing Date: Sun, 8 Jan 2023 00:01:02 +1030 Subject: [PATCH] refactored my nvim config into chris, and started adding lazy by folke (mostly there, needs keys and a bit of config still) --- .config/nvim/init.lua | 43 +-- .config/nvim/lua/{user => chris}/alpha.lua | 2 +- .config/nvim/lua/{user => chris}/autocmd.lua | 0 .../nvim/lua/{user => chris}/autopairs.lua | 0 .../nvim/lua/{user => chris}/bufferline.lua | 0 .config/nvim/lua/{user => chris}/cmp.lua | 2 +- .../nvim/lua/{user => chris}/colorizer.lua | 0 .../nvim/lua/{user => chris}/colorscheme.lua | 0 .config/nvim/lua/{user => chris}/comment.lua | 0 .config/nvim/lua/{user => chris}/cybu.lua | 0 .config/nvim/lua/{user => chris}/dap.lua | 2 +- .config/nvim/lua/{user => chris}/dial.lua | 0 .config/nvim/lua/{user => chris}/dressing.lua | 0 .config/nvim/lua/{user => chris}/fidget.lua | 0 .../nvim/lua/{user => chris}/functions.lua | 0 .config/nvim/lua/{user => chris}/gitsigns.lua | 0 .config/nvim/lua/{user => chris}/harpoon.lua | 0 .config/nvim/lua/{user => chris}/icons.lua | 0 .../nvim/lua/{user => chris}/impatient.lua | 0 .../nvim/lua/{user => chris}/indentline.lua | 0 .config/nvim/lua/chris/init.lua | 38 +++ .config/nvim/lua/{user => chris}/keymaps.lua | 0 .../nvim/lua/{user => chris}/lsp/handlers.lua | 4 +- .config/nvim/lua/{user => chris}/lsp/init.lua | 8 +- .../nvim/lua/{user => chris}/lsp/mason.lua | 18 +- .../nvim/lua/{user => chris}/lsp/null-ls.lua | 0 .../{user => chris}/lsp/settings/clangd.lua | 0 .../{user => chris}/lsp/settings/emmet_ls.lua | 0 .../lsp/settings/omnisharp.lua | 0 .../lua/{user => chris}/lsp/settings/rust.lua | 4 +- .../lsp/settings/shellcheck.lua | 0 .../lsp/settings/sumneko_lua.lua | 0 .../{user => chris}/lsp/settings/tsserver.lua | 0 .../{user => chris}/lsp/settings/yamlls.lua | 0 .config/nvim/lua/{user => chris}/lspsaga.lua | 2 +- .config/nvim/lua/{user => chris}/lualine.lua | 0 .config/nvim/lua/{user => chris}/navic.lua | 2 +- .config/nvim/lua/{user => chris}/neogen.lua | 0 .config/nvim/lua/{user => chris}/noice.lua | 0 .config/nvim/lua/{user => chris}/notify.lua | 2 +- .config/nvim/lua/{user => chris}/numb.lua | 0 .../nvim/lua/{user => chris}/nvim-tree.lua | 2 +- .config/nvim/lua/{user => chris}/options.lua | 0 .config/nvim/lua/{user => chris}/plugins.lua | 30 +- .config/nvim/lua/{user => chris}/spectre.lua | 0 .../lua/{user => chris}/symbols-outline.lua | 2 +- .../nvim/lua/{user => chris}/telescope.lua | 2 +- .../lua/{user => chris}/todo-comments.lua | 2 +- .../nvim/lua/{user => chris}/treesitter.lua | 0 .config/nvim/lua/{user => chris}/whichkey.lua | 0 .config/nvim/lua/{user => chris}/winbar.lua | 0 .config/nvim/lua/{user => chris}/zen-mode.lua | 0 .config/nvim/lua/lazy/config/autocmd.lua | 104 +++++++ .config/nvim/lua/lazy/config/icons.lua | 116 ++++++++ .config/nvim/lua/lazy/config/keymaps.lua | 45 +++ .config/nvim/lua/lazy/config/options.lua | 66 +++++ .config/nvim/lua/lazy/functions.lua | 129 +++++++++ .config/nvim/lua/lazy/init.lua | 38 +++ .config/nvim/lua/lazy/plugins/alpha.lua | 47 +++ .config/nvim/lua/lazy/plugins/cmp.lua | 54 ++++ .config/nvim/lua/lazy/plugins/color.lua | 24 ++ .config/nvim/lua/lazy/plugins/config.lua | 33 +++ .config/nvim/lua/lazy/plugins/dressing.lua | 17 ++ .config/nvim/lua/lazy/plugins/editor.lua | 268 +++++++++++++++++ .config/nvim/lua/lazy/plugins/git.lua | 43 +++ .config/nvim/lua/lazy/plugins/lsp/format.lua | 40 +++ .config/nvim/lua/lazy/plugins/lsp/init.lua | 114 ++++++++ .config/nvim/lua/lazy/plugins/lsp/keymaps.lua | 73 +++++ .config/nvim/lua/lazy/plugins/lualine.lua | 118 ++++++++ .config/nvim/lua/lazy/plugins/noice.lua | 28 ++ .config/nvim/lua/lazy/plugins/snippets.lua | 30 ++ .config/nvim/lua/lazy/plugins/starter.lua | 66 +++++ .config/nvim/lua/lazy/plugins/treesitter.lua | 19 ++ .config/nvim/lua/lazy/plugins/utility.lua | 274 ++++++++++++++++++ 74 files changed, 1828 insertions(+), 83 deletions(-) rename .config/nvim/lua/{user => chris}/alpha.lua (97%) rename .config/nvim/lua/{user => chris}/autocmd.lua (100%) rename .config/nvim/lua/{user => chris}/autopairs.lua (100%) rename .config/nvim/lua/{user => chris}/bufferline.lua (100%) rename .config/nvim/lua/{user => chris}/cmp.lua (99%) rename .config/nvim/lua/{user => chris}/colorizer.lua (100%) rename .config/nvim/lua/{user => chris}/colorscheme.lua (100%) rename .config/nvim/lua/{user => chris}/comment.lua (100%) rename .config/nvim/lua/{user => chris}/cybu.lua (100%) rename .config/nvim/lua/{user => chris}/dap.lua (98%) rename .config/nvim/lua/{user => chris}/dial.lua (100%) rename .config/nvim/lua/{user => chris}/dressing.lua (100%) rename .config/nvim/lua/{user => chris}/fidget.lua (100%) rename .config/nvim/lua/{user => chris}/functions.lua (100%) rename .config/nvim/lua/{user => chris}/gitsigns.lua (100%) rename .config/nvim/lua/{user => chris}/harpoon.lua (100%) rename .config/nvim/lua/{user => chris}/icons.lua (100%) rename .config/nvim/lua/{user => chris}/impatient.lua (100%) rename .config/nvim/lua/{user => chris}/indentline.lua (100%) create mode 100644 .config/nvim/lua/chris/init.lua rename .config/nvim/lua/{user => chris}/keymaps.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/handlers.lua (95%) rename .config/nvim/lua/{user => chris}/lsp/init.lua (68%) rename .config/nvim/lua/{user => chris}/lsp/mason.lua (79%) rename .config/nvim/lua/{user => chris}/lsp/null-ls.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/settings/clangd.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/settings/emmet_ls.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/settings/omnisharp.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/settings/rust.lua (96%) rename .config/nvim/lua/{user => chris}/lsp/settings/shellcheck.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/settings/sumneko_lua.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/settings/tsserver.lua (100%) rename .config/nvim/lua/{user => chris}/lsp/settings/yamlls.lua (100%) rename .config/nvim/lua/{user => chris}/lspsaga.lua (81%) rename .config/nvim/lua/{user => chris}/lualine.lua (100%) rename .config/nvim/lua/{user => chris}/navic.lua (97%) rename .config/nvim/lua/{user => chris}/neogen.lua (100%) rename .config/nvim/lua/{user => chris}/noice.lua (100%) rename .config/nvim/lua/{user => chris}/notify.lua (97%) rename .config/nvim/lua/{user => chris}/numb.lua (100%) rename .config/nvim/lua/{user => chris}/nvim-tree.lua (98%) rename .config/nvim/lua/{user => chris}/options.lua (100%) rename .config/nvim/lua/{user => chris}/plugins.lua (87%) rename .config/nvim/lua/{user => chris}/spectre.lua (100%) rename .config/nvim/lua/{user => chris}/symbols-outline.lua (98%) rename .config/nvim/lua/{user => chris}/telescope.lua (98%) rename .config/nvim/lua/{user => chris}/todo-comments.lua (98%) rename .config/nvim/lua/{user => chris}/treesitter.lua (100%) rename .config/nvim/lua/{user => chris}/whichkey.lua (100%) rename .config/nvim/lua/{user => chris}/winbar.lua (100%) rename .config/nvim/lua/{user => chris}/zen-mode.lua (100%) create mode 100644 .config/nvim/lua/lazy/config/autocmd.lua create mode 100644 .config/nvim/lua/lazy/config/icons.lua create mode 100644 .config/nvim/lua/lazy/config/keymaps.lua create mode 100644 .config/nvim/lua/lazy/config/options.lua create mode 100644 .config/nvim/lua/lazy/functions.lua create mode 100644 .config/nvim/lua/lazy/init.lua create mode 100644 .config/nvim/lua/lazy/plugins/alpha.lua create mode 100644 .config/nvim/lua/lazy/plugins/cmp.lua create mode 100644 .config/nvim/lua/lazy/plugins/color.lua create mode 100644 .config/nvim/lua/lazy/plugins/config.lua create mode 100644 .config/nvim/lua/lazy/plugins/dressing.lua create mode 100644 .config/nvim/lua/lazy/plugins/editor.lua create mode 100644 .config/nvim/lua/lazy/plugins/git.lua create mode 100644 .config/nvim/lua/lazy/plugins/lsp/format.lua create mode 100644 .config/nvim/lua/lazy/plugins/lsp/init.lua create mode 100644 .config/nvim/lua/lazy/plugins/lsp/keymaps.lua create mode 100644 .config/nvim/lua/lazy/plugins/lualine.lua create mode 100644 .config/nvim/lua/lazy/plugins/noice.lua create mode 100644 .config/nvim/lua/lazy/plugins/snippets.lua create mode 100644 .config/nvim/lua/lazy/plugins/starter.lua create mode 100644 .config/nvim/lua/lazy/plugins/treesitter.lua create mode 100644 .config/nvim/lua/lazy/plugins/utility.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index de66866..cfe3038 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,41 +1,2 @@ --- require "user.bufferline" -- unused --- require "user.noice" -- unused --- require "user.winbar" -- top bar, unused - -require "user.impatient" -- good leading -require "user.options" -- my options -require "user.keymaps" -- misc keymaps not part of whichkey -require "user.plugins" -- plugins configuration (packer) -require "user.colorscheme" -- my choice of colorscheme -require "user.lsp" -- lsp configuration -require "user.alpha" -- start/home page for nvim -require "user.autocmd" -- custom autocmds -require "user.autopairs" -- automatically add parirs for brackens quotes etc -require "user.cmp" -- completion configuration -require "user.colorizer" -- highlight colors hexcodes etc -require "user.comment" -- better commenting -require "user.dressing" -- better ui -require "user.dial" -- better incrementing/decrementing -require "user.fidget" -- display lsp server progress -require "user.functions" -- custom functions -require "user.gitsigns" -- gitsigns integration -require "user.harpoon" -- mark files in project and pull them too you -require "user.indentline" -- show indentation levels for code blocks -require "user.lualine" -- pretty and nice statusline plugin -require "user.navic" -- lsp integrated location in code finder/printer -require "user.notify" -- display notifications nicer -require "user.numb" -- peek before you move :10 etc. -require "user.nvim-tree" -- file tree, when needed. -require "user.symbols-outline" -- navigate code symbols -require "user.telescope" -- nice. -require "user.todo-comments" -- highlight TODO and other related comments -require "user.treesitter" -- magic -require "user.whichkey" -- keymaps -require "user.spectre" -- renaming but better -require "user.cybu" -- cycle through current buffers -require "user.dap" -- debugging -require "user.lspsaga" -- bit overkill, using for code action menu -require "user.neogen" -- annotation/doc generator - --- winbar plugin aint working with navic, this could, but I'm using lualine. --- vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}" +--require "lazy" -- my config based on folkes LazyVim starter +require("chris") -- my config based on Christian Chiarullis work diff --git a/.config/nvim/lua/user/alpha.lua b/.config/nvim/lua/chris/alpha.lua similarity index 97% rename from .config/nvim/lua/user/alpha.lua rename to .config/nvim/lua/chris/alpha.lua index 448a26e..6ef425a 100644 --- a/.config/nvim/lua/user/alpha.lua +++ b/.config/nvim/lua/chris/alpha.lua @@ -11,7 +11,7 @@ local function button(sc, txt, key, key_opts) return b end -local icons = require"user.icons" +local icons = require"chris.icons" dashboard.section.header.val = { [[ , __ ___ __. _ __ ` , _ , _ ]], diff --git a/.config/nvim/lua/user/autocmd.lua b/.config/nvim/lua/chris/autocmd.lua similarity index 100% rename from .config/nvim/lua/user/autocmd.lua rename to .config/nvim/lua/chris/autocmd.lua diff --git a/.config/nvim/lua/user/autopairs.lua b/.config/nvim/lua/chris/autopairs.lua similarity index 100% rename from .config/nvim/lua/user/autopairs.lua rename to .config/nvim/lua/chris/autopairs.lua diff --git a/.config/nvim/lua/user/bufferline.lua b/.config/nvim/lua/chris/bufferline.lua similarity index 100% rename from .config/nvim/lua/user/bufferline.lua rename to .config/nvim/lua/chris/bufferline.lua diff --git a/.config/nvim/lua/user/cmp.lua b/.config/nvim/lua/chris/cmp.lua similarity index 99% rename from .config/nvim/lua/user/cmp.lua rename to .config/nvim/lua/chris/cmp.lua index 23f7517..a364f2e 100644 --- a/.config/nvim/lua/user/cmp.lua +++ b/.config/nvim/lua/chris/cmp.lua @@ -33,7 +33,7 @@ local check_backspace = function() return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil end -local icons = require "user.icons" +local icons = require "chris.icons" local kind_icons = icons.kind diff --git a/.config/nvim/lua/user/colorizer.lua b/.config/nvim/lua/chris/colorizer.lua similarity index 100% rename from .config/nvim/lua/user/colorizer.lua rename to .config/nvim/lua/chris/colorizer.lua diff --git a/.config/nvim/lua/user/colorscheme.lua b/.config/nvim/lua/chris/colorscheme.lua similarity index 100% rename from .config/nvim/lua/user/colorscheme.lua rename to .config/nvim/lua/chris/colorscheme.lua diff --git a/.config/nvim/lua/user/comment.lua b/.config/nvim/lua/chris/comment.lua similarity index 100% rename from .config/nvim/lua/user/comment.lua rename to .config/nvim/lua/chris/comment.lua diff --git a/.config/nvim/lua/user/cybu.lua b/.config/nvim/lua/chris/cybu.lua similarity index 100% rename from .config/nvim/lua/user/cybu.lua rename to .config/nvim/lua/chris/cybu.lua diff --git a/.config/nvim/lua/user/dap.lua b/.config/nvim/lua/chris/dap.lua similarity index 98% rename from .config/nvim/lua/user/dap.lua rename to .config/nvim/lua/chris/dap.lua index e86baca..1453cb7 100644 --- a/.config/nvim/lua/user/dap.lua +++ b/.config/nvim/lua/chris/dap.lua @@ -67,7 +67,7 @@ dapui.setup({ }, }) -local icons = require("user.icons") +local icons = require("chris.icons") vim.fn.sign_define("DapBreakpoint", { text = icons.ui.Bug, texthl = "DiagnosticSignError", linehl = "", numhl = "" }) diff --git a/.config/nvim/lua/user/dial.lua b/.config/nvim/lua/chris/dial.lua similarity index 100% rename from .config/nvim/lua/user/dial.lua rename to .config/nvim/lua/chris/dial.lua diff --git a/.config/nvim/lua/user/dressing.lua b/.config/nvim/lua/chris/dressing.lua similarity index 100% rename from .config/nvim/lua/user/dressing.lua rename to .config/nvim/lua/chris/dressing.lua diff --git a/.config/nvim/lua/user/fidget.lua b/.config/nvim/lua/chris/fidget.lua similarity index 100% rename from .config/nvim/lua/user/fidget.lua rename to .config/nvim/lua/chris/fidget.lua diff --git a/.config/nvim/lua/user/functions.lua b/.config/nvim/lua/chris/functions.lua similarity index 100% rename from .config/nvim/lua/user/functions.lua rename to .config/nvim/lua/chris/functions.lua diff --git a/.config/nvim/lua/user/gitsigns.lua b/.config/nvim/lua/chris/gitsigns.lua similarity index 100% rename from .config/nvim/lua/user/gitsigns.lua rename to .config/nvim/lua/chris/gitsigns.lua diff --git a/.config/nvim/lua/user/harpoon.lua b/.config/nvim/lua/chris/harpoon.lua similarity index 100% rename from .config/nvim/lua/user/harpoon.lua rename to .config/nvim/lua/chris/harpoon.lua diff --git a/.config/nvim/lua/user/icons.lua b/.config/nvim/lua/chris/icons.lua similarity index 100% rename from .config/nvim/lua/user/icons.lua rename to .config/nvim/lua/chris/icons.lua diff --git a/.config/nvim/lua/user/impatient.lua b/.config/nvim/lua/chris/impatient.lua similarity index 100% rename from .config/nvim/lua/user/impatient.lua rename to .config/nvim/lua/chris/impatient.lua diff --git a/.config/nvim/lua/user/indentline.lua b/.config/nvim/lua/chris/indentline.lua similarity index 100% rename from .config/nvim/lua/user/indentline.lua rename to .config/nvim/lua/chris/indentline.lua diff --git a/.config/nvim/lua/chris/init.lua b/.config/nvim/lua/chris/init.lua new file mode 100644 index 0000000..3863a61 --- /dev/null +++ b/.config/nvim/lua/chris/init.lua @@ -0,0 +1,38 @@ +-- require "chris.bufferline" -- unused +-- require "chris.noice" -- unused +-- require "chris.winbar" -- top bar, unused + +require "chris.impatient" -- good leading +require "chris.options" -- my options +require "chris.keymaps" -- misc keymaps not part of whichkey +require "chris.plugins" -- plugins configuration (packer) +require "chris.colorscheme" -- my choice of colorscheme +require "chris.lsp" -- lsp configuration +require "chris.alpha" -- start/home page for nvim +require "chris.autocmd" -- custom autocmds +require "chris.autopairs" -- automatically add parirs for brackens quotes etc +require "chris.cmp" -- completion configuration +require "chris.colorizer" -- highlight colors hexcodes etc +require "chris.comment" -- better commenting +require "chris.dressing" -- better ui +require "chris.dial" -- better incrementing/decrementing +require "chris.fidget" -- display lsp server progress +require "chris.functions" -- custom functions +require "chris.gitsigns" -- gitsigns integration +require "chris.harpoon" -- mark files in project and pull them too you +require "chris.indentline" -- show indentation levels for code blocks +require "chris.lualine" -- pretty and nice statusline plugin +require "chris.navic" -- lsp integrated location in code finder/printer +require "chris.notify" -- display notifications nicer +require "chris.numb" -- peek before you move :10 etc. +require "chris.nvim-tree" -- file tree, when needed. +require "chris.symbols-outline" -- navigate code symbols +require "chris.telescope" -- nice. +require "chris.todo-comments" -- highlight TODO and other related comments +require "chris.treesitter" -- magic +require "chris.whichkey" -- keymaps +require "chris.spectre" -- renaming but better +require "chris.cybu" -- cycle through current buffers +require "chris.dap" -- debugging +require "chris.lspsaga" -- bit overkill, using for code action menu +require "chris.neogen" -- annotation/doc generator diff --git a/.config/nvim/lua/user/keymaps.lua b/.config/nvim/lua/chris/keymaps.lua similarity index 100% rename from .config/nvim/lua/user/keymaps.lua rename to .config/nvim/lua/chris/keymaps.lua diff --git a/.config/nvim/lua/user/lsp/handlers.lua b/.config/nvim/lua/chris/lsp/handlers.lua similarity index 95% rename from .config/nvim/lua/user/lsp/handlers.lua rename to .config/nvim/lua/chris/lsp/handlers.lua index fb59a04..d7fac92 100644 --- a/.config/nvim/lua/user/lsp/handlers.lua +++ b/.config/nvim/lua/chris/lsp/handlers.lua @@ -12,7 +12,7 @@ M.capabilities.textDocument.completion.completionItem.snippetSupport = true M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities) M.setup = function() - local icons = require("user.icons") + local icons = require("chris.icons") local signs = { { name = "DiagnosticSignError", text = icons.diagnostics.Error }, { name = "DiagnosticSignWarn", text = icons.diagnostics.Warning }, @@ -121,6 +121,6 @@ function M.remove_augroup(name) end end -vim.cmd([[ command! LspToggleAutoFormat execute 'lua require("user.lsp.handlers").toggle_format_on_save()' ]]) +vim.cmd([[ command! LspToggleAutoFormat execute 'lua require("chris.lsp.handlers").toggle_format_on_save()' ]]) return M diff --git a/.config/nvim/lua/user/lsp/init.lua b/.config/nvim/lua/chris/lsp/init.lua similarity index 68% rename from .config/nvim/lua/user/lsp/init.lua rename to .config/nvim/lua/chris/lsp/init.lua index 6d28657..c700e25 100644 --- a/.config/nvim/lua/user/lsp/init.lua +++ b/.config/nvim/lua/chris/lsp/init.lua @@ -7,10 +7,10 @@ if not status_ok then end -- may add signature in future. --- require "user.lsp.lsp-signature" -require "user.lsp.mason" -require "user.lsp.handlers".setup() -require "user.lsp.null-ls" +-- require "chris.lsp.lsp-signature" +require "chris.lsp.mason" +require "chris.lsp.handlers".setup() +require "chris.lsp.null-ls" local l_status_ok, lsp_lines = pcall(require, "lsp_lines") if not l_status_ok then diff --git a/.config/nvim/lua/user/lsp/mason.lua b/.config/nvim/lua/chris/lsp/mason.lua similarity index 79% rename from .config/nvim/lua/user/lsp/mason.lua rename to .config/nvim/lua/chris/lsp/mason.lua index f6cb135..f6b9e55 100644 --- a/.config/nvim/lua/user/lsp/mason.lua +++ b/.config/nvim/lua/chris/lsp/mason.lua @@ -66,41 +66,41 @@ local opts = {} for _, server in pairs(servers) do opts = { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, + on_attach = require("chris.lsp.handlers").on_attach, + capabilities = require("chris.lsp.handlers").capabilities, } server = vim.split(server, "@", {})[1] if server == "yamlls" then - local yamlls_opts = require("user.lsp.settings.yamlls") + local yamlls_opts = require("chris.lsp.settings.yamlls") opts = vim.tbl_deep_extend("force", yamlls_opts, opts) end if server == "sumneko_lua" then lspconfig.sumneko_lua.setup({ - on_attach = require("user.lsp.handlers").on_attach, + on_attach = require("chris.lsp.handlers").on_attach, }) goto continue end if server == "tsserver" then - local tsserver_opts = require("user.lsp.settings.tsserver") + local tsserver_opts = require("chris.lsp.settings.tsserver") opts = vim.tbl_deep_extend("force", tsserver_opts, opts) end if server == "clangd" then - local clangd_opts = require("user.lsp.settings.clangd") + local clangd_opts = require("chris.lsp.settings.clangd") opts = vim.tbl_deep_extend("force", clangd_opts, opts) end if server == "emmet_ls" then - local emmet_ls_opts = require("user.lsp.settings.emmet_ls") + local emmet_ls_opts = require("chris.lsp.settings.emmet_ls") opts = vim.tbl_deep_extend("force", emmet_ls_opts, opts) end if server == "rust_analyzer" then - local rust_opts = require("user.lsp.settings.rust") + local rust_opts = require("chris.lsp.settings.rust") -- opts = vim.tbl_deep_extend("force", rust_opts, opts) local rust_tools_status_ok, rust_tools = pcall(require, "rust-tools") if not rust_tools_status_ok then @@ -112,7 +112,7 @@ for _, server in pairs(servers) do end if server == "omnisharp" then - local omnisharp_opts = require("user.lsp.settings.omnisharp") + local omnisharp_opts = require("chris.lsp.settings.omnisharp") opts = vim.tbl_deep_extend("force", omnisharp_opts, opts) end diff --git a/.config/nvim/lua/user/lsp/null-ls.lua b/.config/nvim/lua/chris/lsp/null-ls.lua similarity index 100% rename from .config/nvim/lua/user/lsp/null-ls.lua rename to .config/nvim/lua/chris/lsp/null-ls.lua diff --git a/.config/nvim/lua/user/lsp/settings/clangd.lua b/.config/nvim/lua/chris/lsp/settings/clangd.lua similarity index 100% rename from .config/nvim/lua/user/lsp/settings/clangd.lua rename to .config/nvim/lua/chris/lsp/settings/clangd.lua diff --git a/.config/nvim/lua/user/lsp/settings/emmet_ls.lua b/.config/nvim/lua/chris/lsp/settings/emmet_ls.lua similarity index 100% rename from .config/nvim/lua/user/lsp/settings/emmet_ls.lua rename to .config/nvim/lua/chris/lsp/settings/emmet_ls.lua diff --git a/.config/nvim/lua/user/lsp/settings/omnisharp.lua b/.config/nvim/lua/chris/lsp/settings/omnisharp.lua similarity index 100% rename from .config/nvim/lua/user/lsp/settings/omnisharp.lua rename to .config/nvim/lua/chris/lsp/settings/omnisharp.lua diff --git a/.config/nvim/lua/user/lsp/settings/rust.lua b/.config/nvim/lua/chris/lsp/settings/rust.lua similarity index 96% rename from .config/nvim/lua/user/lsp/settings/rust.lua rename to .config/nvim/lua/chris/lsp/settings/rust.lua index 13f3305..9610cd6 100644 --- a/.config/nvim/lua/user/lsp/settings/rust.lua +++ b/.config/nvim/lua/chris/lsp/settings/rust.lua @@ -71,8 +71,8 @@ return { --]] -- cmd = { os.getenv "HOME" .. "/.local/bin/rust-analyzer" }, cmd = { "rustup", "run", "nightly", os.getenv "HOME" .. "/.local/bin/rust-analyzer" }, - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, + on_attach = require("chris.lsp.handlers").on_attach, + capabilities = require("chris.lsp.handlers").capabilities, settings = { ["rust-analyzer"] = { diff --git a/.config/nvim/lua/user/lsp/settings/shellcheck.lua b/.config/nvim/lua/chris/lsp/settings/shellcheck.lua similarity index 100% rename from .config/nvim/lua/user/lsp/settings/shellcheck.lua rename to .config/nvim/lua/chris/lsp/settings/shellcheck.lua diff --git a/.config/nvim/lua/user/lsp/settings/sumneko_lua.lua b/.config/nvim/lua/chris/lsp/settings/sumneko_lua.lua similarity index 100% rename from .config/nvim/lua/user/lsp/settings/sumneko_lua.lua rename to .config/nvim/lua/chris/lsp/settings/sumneko_lua.lua diff --git a/.config/nvim/lua/user/lsp/settings/tsserver.lua b/.config/nvim/lua/chris/lsp/settings/tsserver.lua similarity index 100% rename from .config/nvim/lua/user/lsp/settings/tsserver.lua rename to .config/nvim/lua/chris/lsp/settings/tsserver.lua diff --git a/.config/nvim/lua/user/lsp/settings/yamlls.lua b/.config/nvim/lua/chris/lsp/settings/yamlls.lua similarity index 100% rename from .config/nvim/lua/user/lsp/settings/yamlls.lua rename to .config/nvim/lua/chris/lsp/settings/yamlls.lua diff --git a/.config/nvim/lua/user/lspsaga.lua b/.config/nvim/lua/chris/lspsaga.lua similarity index 81% rename from .config/nvim/lua/user/lspsaga.lua rename to .config/nvim/lua/chris/lspsaga.lua index 41da249..ba43a9e 100644 --- a/.config/nvim/lua/user/lspsaga.lua +++ b/.config/nvim/lua/chris/lspsaga.lua @@ -3,7 +3,7 @@ if not status_ok then return end -local icons = require "user.icons" +local icons = require "chris.icons" lspsaga.init_lsp_saga({ code_action_icon = icons.diagnostics.Hint diff --git a/.config/nvim/lua/user/lualine.lua b/.config/nvim/lua/chris/lualine.lua similarity index 100% rename from .config/nvim/lua/user/lualine.lua rename to .config/nvim/lua/chris/lualine.lua diff --git a/.config/nvim/lua/user/navic.lua b/.config/nvim/lua/chris/navic.lua similarity index 97% rename from .config/nvim/lua/user/navic.lua rename to .config/nvim/lua/chris/navic.lua index 55f6547..fbf86a1 100644 --- a/.config/nvim/lua/user/navic.lua +++ b/.config/nvim/lua/chris/navic.lua @@ -4,7 +4,7 @@ if not status_ok then return end -local icons = require("user.icons") +local icons = require("chris.icons") navic.setup({ icons = { diff --git a/.config/nvim/lua/user/neogen.lua b/.config/nvim/lua/chris/neogen.lua similarity index 100% rename from .config/nvim/lua/user/neogen.lua rename to .config/nvim/lua/chris/neogen.lua diff --git a/.config/nvim/lua/user/noice.lua b/.config/nvim/lua/chris/noice.lua similarity index 100% rename from .config/nvim/lua/user/noice.lua rename to .config/nvim/lua/chris/noice.lua diff --git a/.config/nvim/lua/user/notify.lua b/.config/nvim/lua/chris/notify.lua similarity index 97% rename from .config/nvim/lua/user/notify.lua rename to .config/nvim/lua/chris/notify.lua index bd000a7..29cc16d 100644 --- a/.config/nvim/lua/user/notify.lua +++ b/.config/nvim/lua/chris/notify.lua @@ -3,7 +3,7 @@ if not status_ok then return end -local icons = require "user.icons" +local icons = require "chris.icons" notify.setup { -- Animation style (see below for details) diff --git a/.config/nvim/lua/user/numb.lua b/.config/nvim/lua/chris/numb.lua similarity index 100% rename from .config/nvim/lua/user/numb.lua rename to .config/nvim/lua/chris/numb.lua diff --git a/.config/nvim/lua/user/nvim-tree.lua b/.config/nvim/lua/chris/nvim-tree.lua similarity index 98% rename from .config/nvim/lua/user/nvim-tree.lua rename to .config/nvim/lua/chris/nvim-tree.lua index 310a7a2..02b0e61 100644 --- a/.config/nvim/lua/user/nvim-tree.lua +++ b/.config/nvim/lua/chris/nvim-tree.lua @@ -8,7 +8,7 @@ if not config_status_ok then return end -local icons = require "user.icons" +local icons = require "chris.icons" local tree_cb = nvim_tree_config.nvim_tree_callback diff --git a/.config/nvim/lua/user/options.lua b/.config/nvim/lua/chris/options.lua similarity index 100% rename from .config/nvim/lua/user/options.lua rename to .config/nvim/lua/chris/options.lua diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/chris/plugins.lua similarity index 87% rename from .config/nvim/lua/user/plugins.lua rename to .config/nvim/lua/chris/plugins.lua index 89379c9..bfef9c8 100644 --- a/.config/nvim/lua/user/plugins.lua +++ b/.config/nvim/lua/chris/plugins.lua @@ -46,9 +46,9 @@ return packer.startup(function(use) use("wbthomason/packer.nvim") -- Have packer manage inself -- Lua Development - use("nvim-lua/plenary.nvim") -- useful lua functions - use("nvim-lua/popup.nvim") - use("folke/neodev.nvim") + --use("nvim-lua/plenary.nvim") -- useful lua functions + --use("nvim-lua/popup.nvim") + --use("folke/neodev.nvim") -- LSP use("neovim/nvim-lspconfig") -- enable LSP @@ -73,9 +73,9 @@ return packer.startup(function(use) use("hrsh7th/cmp-nvim-lsp") -- lsp completions use("hrsh7th/cmp-nvim-lua") - -- Snippet - use("L3MON4D3/LuaSnip") -- snippet engine - use("rafamadriz/friendly-snippets") -- a collection of useful snippets + -- Snippet { + --use("L3MON4D3/LuaSnip") -- snippet engine + --use("rafamadriz/friendly-snippets") -- a collection of useful snippets -- Syntax/Treesitter use("nvim-treesitter/nvim-treesitter") @@ -98,17 +98,17 @@ return packer.startup(function(use) use("RRethy/nvim-base16") -- Utility - use("rcarriga/nvim-notify") + --use("rcarriga/nvim-notify") use("stevearc/dressing.nvim") - use("moll/vim-bbye") - use("lewis6991/impatient.nvim") - use("ghillb/cybu.nvim") - use("mbbill/undotree") - use("MunifTanjim/nui.nvim") + --use("moll/vim-bbye") + --use("lewis6991/impatient.nvim") + --use("ghillb/cybu.nvim") + --use("mbbill/undotree") + --use("MunifTanjim/nui.nvim") -- noice -- Icons - use("kyazdani42/nvim-web-devicons") + --use("kyazdani42/nvim-web-devicons") -- Debugging use("mfussenegger/nvim-dap") @@ -119,10 +119,10 @@ return packer.startup(function(use) -- bufferline -- Statusline - use("nvim-lualine/lualine.nvim") + --use("nvim-lualine/lualine.nvim") -- Startup - use("goolord/alpha-nvim") + --use("goolord/alpha-nvim") -- Indent use("lukas-reineke/indent-blankline.nvim") diff --git a/.config/nvim/lua/user/spectre.lua b/.config/nvim/lua/chris/spectre.lua similarity index 100% rename from .config/nvim/lua/user/spectre.lua rename to .config/nvim/lua/chris/spectre.lua diff --git a/.config/nvim/lua/user/symbols-outline.lua b/.config/nvim/lua/chris/symbols-outline.lua similarity index 98% rename from .config/nvim/lua/user/symbols-outline.lua rename to .config/nvim/lua/chris/symbols-outline.lua index de902bf..ae29ec4 100644 --- a/.config/nvim/lua/user/symbols-outline.lua +++ b/.config/nvim/lua/chris/symbols-outline.lua @@ -1,4 +1,4 @@ -local icons = require "user.icons" +local icons = require "chris.icons" vim.g.symbols_outline = { highlight_hovered_item = true, show_guides = true, diff --git a/.config/nvim/lua/user/telescope.lua b/.config/nvim/lua/chris/telescope.lua similarity index 98% rename from .config/nvim/lua/user/telescope.lua rename to .config/nvim/lua/chris/telescope.lua index da0a0a9..23372d4 100644 --- a/.config/nvim/lua/user/telescope.lua +++ b/.config/nvim/lua/chris/telescope.lua @@ -4,7 +4,7 @@ if not status_ok then end local actions = require "telescope.actions" -local icons = require "user.icons" +local icons = require "chris.icons" telescope.setup { defaults = { diff --git a/.config/nvim/lua/user/todo-comments.lua b/.config/nvim/lua/chris/todo-comments.lua similarity index 98% rename from .config/nvim/lua/user/todo-comments.lua rename to .config/nvim/lua/chris/todo-comments.lua index e54170c..0470695 100644 --- a/.config/nvim/lua/user/todo-comments.lua +++ b/.config/nvim/lua/chris/todo-comments.lua @@ -3,7 +3,7 @@ if not status_ok then return end -local icons = require "user.icons" +local icons = require "chris.icons" local error_red = "#F44747" local warning_orange = "#ff8800" diff --git a/.config/nvim/lua/user/treesitter.lua b/.config/nvim/lua/chris/treesitter.lua similarity index 100% rename from .config/nvim/lua/user/treesitter.lua rename to .config/nvim/lua/chris/treesitter.lua diff --git a/.config/nvim/lua/user/whichkey.lua b/.config/nvim/lua/chris/whichkey.lua similarity index 100% rename from .config/nvim/lua/user/whichkey.lua rename to .config/nvim/lua/chris/whichkey.lua diff --git a/.config/nvim/lua/user/winbar.lua b/.config/nvim/lua/chris/winbar.lua similarity index 100% rename from .config/nvim/lua/user/winbar.lua rename to .config/nvim/lua/chris/winbar.lua diff --git a/.config/nvim/lua/user/zen-mode.lua b/.config/nvim/lua/chris/zen-mode.lua similarity index 100% rename from .config/nvim/lua/user/zen-mode.lua rename to .config/nvim/lua/chris/zen-mode.lua diff --git a/.config/nvim/lua/lazy/config/autocmd.lua b/.config/nvim/lua/lazy/config/autocmd.lua new file mode 100644 index 0000000..f8eadaf --- /dev/null +++ b/.config/nvim/lua/lazy/config/autocmd.lua @@ -0,0 +1,104 @@ +vim.api.nvim_create_autocmd({ "User" }, { + pattern = { "AlphaReady" }, + callback = function() + vim.cmd([[ + set laststatus=0 | autocmd BufUnload set laststatus=3 + ]]) + end, +}) + +vim.api.nvim_create_autocmd({ "VimResized" }, { + callback = function() + vim.cmd("tabdo wincmd =") + end, +}) + +vim.api.nvim_create_autocmd({ "CmdWinEnter" }, { + callback = function() + vim.cmd("quit") + end, +}) + +vim.api.nvim_create_autocmd({ "BufWinEnter" }, { + callback = function() + vim.cmd("set formatoptions-=cro") + end, +}) + +-- highlight on yank +vim.api.nvim_create_autocmd({ "TextYankPost" }, { + callback = function() + vim.highlight.on_yank() + end, +}) + +vim.api.nvim_create_autocmd({ "VimEnter" }, { + callback = function() + vim.cmd("hi link illuminatedWord LspReferenceText") + end, +}) + +-- go to last loc when opening a buffer +vim.api.nvim_create_autocmd("BufReadPost", { + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, +}) + +-- close some filetypes with +vim.api.nvim_create_autocmd("FileType", { + pattern = { + "qf", + "help", + "man", + "notify", + "lspinfo", + "spectre_panel", + "startuptime", + "tsplayground", + "PlenaryTestPopup", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) + end, +}) + +-- add spellcheck and wrapping to some file types +vim.api.nvim_create_autocmd("FileType", { + pattern = { "gitcommit", "markdown" }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +-- Prevent auto comment on next line +vim.cmd([[autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o]]) + +-- Set filetype to tex for .tex files? +vim.cmd([[autocmd BufRead,BufNewFile *.tex set filetype=tex]]) + +-- Trim whitespace from files on save +vim.cmd [[ +autocmd BufWritePre * let currPos = getpos(".") +autocmd BufWritePre * %s/\s\+$//e +autocmd BufWritePre * %s/\n\+\%$//e +autocmd BufWritePre *.[ch] %s/\%$/\r/e +autocmd BufWritePre * cal cursor(currPos[1], currPos[2]) +]] + +-- Recompile and restart Xmonad on save of config file for Xmonad or Xmobar +vim.cmd([[autocmd BufWritePost ~/.xmonad/xmonad.hs,~/.config/xmobar/xmobar-main.hs,~/.config/xmobar/xmobar-sub.hs,~/.config/xmobar/xmobar-single.hs !xmonad --recompile && xmonad --restart]]) + +-- Run custom textclear command when exiting a .tex file (cleanup files) +vim.cmd([[autocmd VimLeave *.tex !texclear %]]) + +-- Run install when editing my scripts +vim.cmd([[ +autocmd BufWritePost ~/repos/inks-scripts/scripts/** !~/repos/inks-scripts/install +]]) diff --git a/.config/nvim/lua/lazy/config/icons.lua b/.config/nvim/lua/lazy/config/icons.lua new file mode 100644 index 0000000..f1fa05c --- /dev/null +++ b/.config/nvim/lua/lazy/config/icons.lua @@ -0,0 +1,116 @@ +-- https://github.com/microsoft/vscode/blob/main/src/vs/base/common/codicons.ts +-- go to the above and then enter u and the symbold should appear +-- or go here and upload the font file: https://mathew-kurian.github.io/CharacterMap/ +-- find more here: https://www.nerdfonts.com/cheat-sheet +return { + kind = { + Text = "", + -- Method = "m", + Function = "", + -- Constructor = "", + Method = "", + -- Function = "", + Constructor = "", + Field = "", + -- Variable = "", + Variable = "", + Namespace = "פּ", + Class = "", + Interface = "", + -- Module = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Key = "k", + -- Keyword = "", + Keyword = "", + -- Snippet = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", + }, + type = { + Array = "", + Number = "", + String = "", + Boolean = "蘒", + Null = "ﳠ", + Object = "", + }, + documents = { + File = "", + Files = "", + Folder = "", + OpenFolder = "", + }, + git = { + Add = "", + Mod = "", + Remove = "", + Ignore = "", + Rename = "", + Diff = "", + Repo = "", + Octoface = "", + }, + ui = { + ArrowClosed = "", + ArrowOpen = "", + Lock = "", + Circle = "", + BigCircle = "", + BigUnfilledCircle = "", + Close = "", + NewFile = "", + Search = "", + Lightbulb = "", + Project = "", + Dashboard = "", + History = "", + Comment = "", + Bug = "", + Code = "", + Telescope = "", + Gear = "", + Package = "", + List = "", + SignIn = "", + SignOut = "", + Check = "", + Fire = "", + Note = "", + BookMark = "", + Pencil = "", + -- ChevronRight = "", + ChevronRight = ">", + Table = "", + Calendar = "", + CloudDownload = "", + }, + diagnostics = { + Error = "", + Warning = "", + Information = "", + Question = "", + Hint = "", + }, + misc = { + Robot = "ﮧ", + Squirrel = "", + Tag = "", + Watch = "", + Smiley = "ﲃ", + Package = "", + CircuitBoard = "", + }, +} diff --git a/.config/nvim/lua/lazy/config/keymaps.lua b/.config/nvim/lua/lazy/config/keymaps.lua new file mode 100644 index 0000000..8727e95 --- /dev/null +++ b/.config/nvim/lua/lazy/config/keymaps.lua @@ -0,0 +1,45 @@ +local opts = { noremap = true, silent = true } + +local map = vim.api.nvim_set_keymap + +-- NORMAL +-- Move text up and down +map("n", "", ":m .-2==", opts) +map("n", "", ":m .+1==", opts) + +-- Copy/Paste +map("n", "", '"+y', opts) +map("n", "", '"+y', opts) + +-- Save +map("n", "", ":w", opts) + +-- Switch between buffers +map("n", "", ":CybuNext", opts) +map("n", "", ":CybuPrev", opts) + +-- center after up and down movements +map("n", "", "zz", opts) +map("n", "", "zz", opts) + +-- INSERT +-- Easy exit insert mode +map("i", "jk", "", opts) + +-- Paste +map("i", "", '"+y', opts) + +-- Save +map("i", "", ":wa", opts) + +-- VISUAL +-- Indenting +map("v", "<", "", ">gv", opts) + +-- Move text up and down +map("v", "", ":m .+1==V", opts) +map("v", "", ":m .-2==V", opts) + +-- Copy +map("v", "", '"+y', opts) diff --git a/.config/nvim/lua/lazy/config/options.lua b/.config/nvim/lua/lazy/config/options.lua new file mode 100644 index 0000000..b81deec --- /dev/null +++ b/.config/nvim/lua/lazy/config/options.lua @@ -0,0 +1,66 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +local options = { + backup = false, -- creates a backup file + clipboard = "unnamedplus", -- gives nvim access to clipboard + cmdheight = 1, -- more space in nvim cmd line + completeopt = { "menuone", "noselect" }, -- cmp related + conceallevel = 3, -- don't hide `` in md + fileencoding = "utf-8", + hlsearch = false, + ignorecase = true, + mouse = "a", -- allow use of mouse (bad I know but sometimes useful) + pumheight = 10, -- popup menu height + showmode = true, + smartcase = true, + smartindent = true, + splitbelow = true, + splitright = true, + swapfile = false, + termguicolors = true, + timeoutlen = 500, + ttimeoutlen = 10, + undofile = true, + updatetime = 100, + writebackup = false, + expandtab = true, -- use spaces instead of tab + shiftwidth = 4, -- insert 4 spaces for indentation + tabstop = 4, -- insert 4 spaces for tab + cursorline = false, + number = true, + laststatus = 3, + showcmd = false, + ruler = false, + relativenumber = true, + numberwidth = 2, + signcolumn = "yes", + wrap = false, + scrolloff = 8, + sidescrolloff = 8, + guifont = "monospace:h17", + title = true, + spelllang = "en_us", + autowrite = true, + confirm = true, + formatoptions = "jcroqlnt", -- tcqj + grepformat = "%f:%l:%c:%m", + grepprg = "rg --vimgrep", + guifont = "FiraCode Nerd Font:h11", + +} + +vim.opt.fillchars = vim.opt.fillchars + 'eob: ' + +vim.opt.shortmess:append "c" + +for k, v in pairs(options) do + vim.opt[k] = v +end + +vim.cmd "set whichwrap+=<,>,[,],h,l" +vim.cmd "set colorcolumn=80" +vim.cmd [[set iskeyword+=-]] + +-- fix markdown indentation settings +vim.g.markdown_recommended_style = 0 diff --git a/.config/nvim/lua/lazy/functions.lua b/.config/nvim/lua/lazy/functions.lua new file mode 100644 index 0000000..e4a8eb4 --- /dev/null +++ b/.config/nvim/lua/lazy/functions.lua @@ -0,0 +1,129 @@ +local M = {} + +M.root_patterns = { ".git", "/lua" } + +---@param on_attach fun(client, buffer) +function M.on_attach(on_attach) + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local buffer = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + on_attach(client, buffer) + end, + }) +end + +-- returns the root directory based on: +-- * lsp workspace folders +-- * lsp root_dir +-- * root pattern of filename of the current buffer +-- * root pattern of cwd +---@return string +function M.get_root() + ---@type string? + local path = vim.api.nvim_buf_get_name(0) + path = path ~= "" and vim.loop.fs_realpath(path) or nil + ---@type string[] + local roots = {} + if path then + for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do + local workspace = client.config.workspace_folders + local paths = workspace and vim.tbl_map(function(ws) + return vim.uri_to_fname(ws.uri) + end, workspace) or client.config.root_dir and { client.config.root_dir } or {} + for _, p in ipairs(paths) do + local r = vim.loop.fs_realpath(p) + if path:find(r, 1, true) then + roots[#roots + 1] = r + end + end + end + end + table.sort(roots, function(a, b) + return #a > #b + end) + ---@type string? + local root = roots[1] + if not root then + path = path and vim.fs.dirname(path) or vim.loop.cwd() + ---@type string? + root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1] + root = root and vim.fs.dirname(root) or vim.loop.cwd() + end + ---@cast root string + return root +end + +---@param silent boolean? +---@param values? {[1]:any, [2]:any}function +function M.toggle(option, silent, values) + if values then + if vim.opt_local[option]:get() == values[1] then + vim.opt_local[option] = values[2] + else + vim.opt_local[option] = values[1] + end + return vim.notify( + "Set " .. option .. " to " .. vim.opt_local[option]:get(), + vim.log.levels.INFO, + { title = "Option" } + ) + end + vim.opt_local[option] = not vim.opt_local[option]:get() + if not silent then + vim.notify( + (vim.opt_local[option]:get() and "Enabled" or "Disabled") .. " " .. option, + vim.log.levels.INFO, + { title = "Option" } + ) + end +end + +local enabled = true +function M.toggle_diagnostics() + enabled = not enabled + if enabled then + vim.diagnostic.enable() + vim.notify("Enabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" }) + else + vim.diagnostic.disable() + vim.notify("Disabled diagnostics", vim.log.levels.INFO, { title = "Diagnostics" }) + end +end + +function M.smart_quit() + local bufnr = vim.api.nvim_get_current_buf() + local modified = vim.api.nvim_buf_get_option(bufnr, "modified") + if modified then + vim.ui.input({ + prompt = "You have unsaved changes. Quit anyway? (y/n) ", + }, function(input) + if input == "y" then + vim.cmd "q!" + end + end) + else + vim.cmd "q!" + end +end + +function M.isempty(s) + return s == nil or s == "" +end + +function M.get_buf_option(opt) + local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt) + if not status_ok then + return nil + else + return buf_option + end +end + +function M.telescope(builtin, opts) + return function() + require("telescope.builtin")[builtin](vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {})) + end +end + +return M diff --git a/.config/nvim/lua/lazy/init.lua b/.config/nvim/lua/lazy/init.lua new file mode 100644 index 0000000..538580d --- /dev/null +++ b/.config/nvim/lua/lazy/init.lua @@ -0,0 +1,38 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) +end + +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) + +require("lazy").setup({ + spec = "lazy.plugins", + defaults = { lazy = true, version = "*" }, + checker = { enabled = true }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) + +vim.keymap.set("n", "l", ":Lazy") + +vim.cmd("colorscheme base16-gruvbox-dark-medium") diff --git a/.config/nvim/lua/lazy/plugins/alpha.lua b/.config/nvim/lua/lazy/plugins/alpha.lua new file mode 100644 index 0000000..ce25793 --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/alpha.lua @@ -0,0 +1,47 @@ +return { + { + "goolord/alpha-nvim" , + config = function() + local dashboard = require"alpha.themes.dashboard" + + local function button(sc, txt, key, key_opts) + local b = dashboard.button(sc, txt, key, key_opts) + b.opts.hl_shortcut = "Macro" + return b + end + + local icons = require"user.icons" + + dashboard.section.header.val = { + [[ , __ ___ __. _ __ ` , _ , _ ]], + [[ |' `. .' ` .' \ | / | |' `|' `.]], + [[ | | |----' | | ` / | | | |]], + [[ / | `.___, `._.' \/ / / ' /]], + } + + dashboard.section.buttons.val = { + button("f", icons.documents.Files .. " Find file", ":Telescope find_files "), + button("e", icons.ui.NewFile .. " New file", ":ene startinsert "), + button("r", icons.ui.History .. " Recent files", ":Telescope oldfiles "), + button("t", icons.ui.List .. " Find text", ":Telescope live_grep "), + button("c", icons.ui.Gear .. " Config", ":e ~/.config/nvim/init.lua "), + button("u", icons.ui.CloudDownload .. " Update", ":PackerSync"), + button("q", icons.ui.SignOut .. " Quit", ":qa"), + } + + dashboard.section.footer.val = { + [[┬┌┐┌┬┌─┬ ┌─┐┌┬┐┌┐ ┬ ┌─┐┌┬┐┌─┐┌─┐┌┬┐]], + [[││││├┴┐│ ├┤ │ ├┴┐│ │ │ │ │ │ ││││]], + [[┴┘└┘┴ ┴┴─┘└─┘ ┴ └─┘┴─┘└─┘ ┴o└─┘└─┘┴ ┴]], + } + + dashboard.section.header.opts.hl = "Include" + dashboard.section.buttons.opts.hl = "Macro" + dashboard.section.footer.opts.hl = "Type" + + dashboard.opts.opts.noautocmd = true + + require"alpha".setup(dashboard.opts) + end, + } +} diff --git a/.config/nvim/lua/lazy/plugins/cmp.lua b/.config/nvim/lua/lazy/plugins/cmp.lua new file mode 100644 index 0000000..9dc74bb --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/cmp.lua @@ -0,0 +1,54 @@ +return { + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-emoji", + "saadparwaiz1/cmp_luasnip", + }, + config = function() + local cmp = require("cmp") + cmp.setup({ + completion = { + completeopt = "menu,menuone,noinsert", + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + { name = "emoji" }, + }), + formatting = { + format = function(_, item) + local icons = require("lazy.config.icons").kinds + if icons[item.kind] then + item.kind = icons[item.kind] .. item.kind + end + return item + end, + }, + experimental = { + ghost_text = { + hl_group = "LspCodeLens", + }, + }, + }) + end, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/color.lua b/.config/nvim/lua/lazy/plugins/color.lua new file mode 100644 index 0000000..ea0819b --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/color.lua @@ -0,0 +1,24 @@ +return { + { + "sainnhe/gruvbox-material", + lazy = true, + }, + { + "sainnhe/sonokai", + lazy = true, + }, + { + "dracula/vim", + lazy = true, + }, + { + "RRethy/nvim-base16", + lazy = true, + }, + { + "NvChad/nvim-colorizer.lua", + config = function() + require("colorizer").setup({}) + end, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/config.lua b/.config/nvim/lua/lazy/plugins/config.lua new file mode 100644 index 0000000..c80a8bb --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/config.lua @@ -0,0 +1,33 @@ +local function load(name) + local Util = require("lazy.core.util") + -- always load lazyvim, then user file + for _, mod in ipairs({ "lazy.config." .. name, "config." .. name }) do + Util.try(function() + require(mod) + end, { + msg = "Failed loading " .. mod, + on_error = function(msg) + local modpath = require("lazy.core.cache").find(mod) + if modpath then + Util.error(msg) + end + end, + }) + end +end + +-- load options here, before lazy init while sourcing plugin modules +-- this is needed to make sure options will be correctly applied +-- after installing missing plugins +load("options") + +-- autocmds and keymaps can wait to load +vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + load("autocmds") + load("keymaps") + end, +}) + +return {} diff --git a/.config/nvim/lua/lazy/plugins/dressing.lua b/.config/nvim/lua/lazy/plugins/dressing.lua new file mode 100644 index 0000000..2d44593 --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/dressing.lua @@ -0,0 +1,17 @@ +return { + { + "stevearc/dressing.nvim", + init = function() + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.select = function(...) + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.select(...) + end + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.input = function(...) + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.input(...) + end + end, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/editor.lua b/.config/nvim/lua/lazy/plugins/editor.lua new file mode 100644 index 0000000..d04c43f --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/editor.lua @@ -0,0 +1,268 @@ +local util = require"lazy.functions" + +return { + { + "kyazdani42/nvim-tree.lua", + config = function() + local nvim_tree_config = require"nvim-tree.config" + local icons = require "user.icons" + + local tree_cb = nvim_tree_config.nvim_tree_callback + + nvim_tree.setup { + hijack_directories = { + enable = false, + }, + ignore_ft_on_setup = { + "alpha", + }, + filters = { + custom = { ".git" }, + exclude = { ".gitignore" }, + }, + hijack_cursor = false, + update_cwd = true, + renderer = { + add_trailing = false, + group_empty = false, + highlight_git = false, + highlight_opened_files = "none", + root_folder_modifier = ":t", + indent_markers = { + enable = false, + icons = { + corner = "└ ", + edge = "│ ", + none = " ", + }, + }, + icons = { + webdev_colors = true, + git_placement = "before", + padding = " ", + symlink_arrow = " ➛ ", + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + }, + glyphs = { + default = "", + symlink = "", + folder = { + arrow_open = icons.ui.ArrowOpen, + arrow_closed = icons.ui.ArrowClosed, + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + untracked = "U", + deleted = "", + ignored = "◌", + }, + }, + }, + }, + diagnostics = { + enable = true, + icons = { + hint = icons.diagnostics.Hint, + info = icons.diagnostics.Information, + warning = icons.diagnostics.Warning, + error = icons.diagnostics.Error, + }, + }, + update_focused_file = { + enable = true, + update_cwd = true, + ignore_list = {}, + }, + git = { + enable = true, + ignore = true, + timeout = 500, + }, + view = { + width = 30, + hide_root_folder = false, + side = "left", + mappings = { + custom_only = false, + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + number = false, + relativenumber = false, + }, + actions = { + open_file = { + quit_on_open = true, + } + } + } + end, + }, + { + "windwp/nvim-spectre", + -- stylua: ignore + keys = { + { "sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)" }, + }, + }, + { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + keys = { + { "/", util.telescope("live_grep"), desc = "Find in Files (Grep)" }, + { "", util.telescope("find_files"), desc = "Find Files (root dir)" }, + { "fb", "Telescope buffers", desc = "Buffers" }, + { "ff", util.telescope("find_files"), desc = "Find Files (root dir)" }, + { "fF", util.telescope("find_files", { cwd = false }), desc = "Find Files (cwd)" }, + { "fr", "Telescope oldfiles", desc = "Recent" }, + { "gc", "Telescope git_commits", desc = "commits" }, + { "gs", "Telescope git_status", desc = "status" }, + { "ha", "Telescope autocommands", desc = "Auto Commands" }, + { "hc", "Telescope commands", desc = "Commands" }, + { "hf", "Telescope filetypes", desc = "File Types" }, + { "hh", "Telescope help_tags", desc = "Help Pages" }, + { "hk", "Telescope keymaps", desc = "Key Maps" }, + { "hm", "Telescope man_pages", desc = "Man Pages" }, + { "ho", "Telescope vim_options", desc = "Options" }, + { "hs", "Telescope highlights", desc = "Search Highlight Groups" }, + { "ht", "Telescope builtin", desc = "Telescope" }, + { "sb", "Telescope current_buffer_fuzzy_find", desc = "Buffer" }, + { "sc", "Telescope command_history", desc = "Command History" }, + { "sg", util.telescope("live_grep"), desc = "Grep (root dir)" }, + { "sG", util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, + { "sm", "Telescope marks", desc = "Jump to Mark" }, + { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, + { ":", "Telescope command_history", desc = "Command History" }, + { + "ss", + util.telescope("lsp_document_symbols", { + symbols = { + "Class", + "Function", + "Method", + "Constructor", + "Interface", + "Module", + "Struct", + "Trait", + "Field", + "Property", + }, + }), + desc = "Goto Symbol", + }, + }, + config = { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + mappings = { + i = { + [""] = function(...) + return require("trouble.providers.telescope").open_with_trouble(...) + end, + [""] = function() + util.telescope("find_files", { no_ignore = true })() + end, + [""] = function() + util.telescope("find_files", { hidden = true })() + end, + [""] = function(...) + return require("telescope.actions").cycle_history_next(...) + end, + [""] = function(...) + return require("telescope.actions").cycle_history_prev(...) + end, + }, + }, + }, + }, + }, +{ + "folke/which-key.nvim", + event = "VeryLazy", + config = function() + local wk = require("which-key") + wk.setup({ + plugins = { spelling = true }, + key_labels = { [""] = "SPC" }, + }) + wk.register({ + mode = { "n", "v" }, + ["g"] = { name = "+goto" }, + ["]"] = { name = "+next" }, + ["["] = { name = "+prev" }, + ["b"] = { name = "+buffer" }, + ["c"] = { name = "+code" }, + ["f"] = { name = "+file" }, + ["g"] = { name = "+git" }, + ["h"] = { name = "+help" }, + ["n"] = { name = "+noice" }, + ["o"] = { name = "+open" }, + ["q"] = { name = "+quit/session" }, + ["s"] = { name = "+search" }, + ["t"] = { name = "+toggle" }, + ["x"] = { name = "+diagnostics/quickfix" }, + ["w"] = { name = "+windows" }, + [""] = { name = "+tabs" }, + }) + end, + }, +{ + "RRethy/vim-illuminate", + event = "BufReadPost", + config = function() + require("illuminate").configure({ delay = 200 }) + end, + -- stylua: ignore + keys = { + { "]]", function() require("illuminate").goto_next_reference(false) end, desc = "Next Reference", }, + { "[[", function() require("illuminate").goto_prev_reference(false) end, desc = "Prev Reference" }, + }, + }, + { + "folke/trouble.nvim", + cmd = { "TroubleToggle", "Trouble" }, + config = { use_diagnostic_signs = true }, + keys = { + { "xx", "TroubleToggle document_diagnostics", desc = "Document Diagnostics (Trouble)" }, + { "xX", "TroubleToggle workspace_diagnostics", desc = "Workspace Diagnostics (Trouble)" }, + }, + }, + { + "folke/todo-comments.nvim", + cmd = { "TodoTrouble", "TodoTelescope" }, + event = "BufReadPost", + config = true, + -- stylua: ignore + keys = { + { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, + { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, + { "xt", "TodoTrouble", desc = "Todo Trouble" }, + { "xtt", "TodoTrouble keywords=TODO,FIX,FIXME", desc = "Todo Trouble" }, + { "xT", "TodoTelescope", desc = "Todo Telescope" }, + }, + }, + { + "numToStr/Comment.nvim", + config = function() + require"Comment".setup({}) + end, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/git.lua b/.config/nvim/lua/lazy/plugins/git.lua new file mode 100644 index 0000000..5323b32 --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/git.lua @@ -0,0 +1,43 @@ +return { + { + "lewis6991/gitsigns.nvim", + event = "BufReadPre", + config = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "契" }, + topdelete = { text = "契" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + on_attach = function(buffer) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + end + + -- stylua: ignore start + map("n", "]h", gs.prev_hunk, "Next Hunk") + map("n", "[h", gs.next_hunk, "Prev Hunk") + map({ "n", "v" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") + map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") + map("n", "ghS", gs.stage_buffer, "Stage Buffer") + map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") + map("n", "ghR", gs.reset_buffer, "Reset Buffer") + map("n", "ghp", gs.preview_hunk, "Preview Hunk") + map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") + map("n", "ghd", gs.diffthis, "Diff This") + map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") + end, + }, + }, + { + "f-person/git-blame.nvim", + }, + { + "tpope/vim-fugitive", + }, +} diff --git a/.config/nvim/lua/lazy/plugins/lsp/format.lua b/.config/nvim/lua/lazy/plugins/lsp/format.lua new file mode 100644 index 0000000..01dabf4 --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/lsp/format.lua @@ -0,0 +1,40 @@ +local M = {} + +M.autoformat = true + +function M.toggle() + M.autoformat = not M.autoformat + vim.notify(M.autoformat and "Enabled format on save" or "Disabled format on save") +end + +function M.format() + local buf = vim.api.nvim_get_current_buf() + local ft = vim.bo[buf].filetype + local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0 + + vim.lsp.buf.format({ + bufnr = buf, + filter = function(client) + if have_nls then + return client.name == "null-ls" + end + return client.name ~= "null-ls" + end, + }) +end + +function M.on_attach(client, buf) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("LspFormat." .. buf, {}), + buffer = buf, + callback = function() + if M.autoformat then + M.format() + end + end, + }) + end +end + +return M diff --git a/.config/nvim/lua/lazy/plugins/lsp/init.lua b/.config/nvim/lua/lazy/plugins/lsp/init.lua new file mode 100644 index 0000000..69ca08d --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/lsp/init.lua @@ -0,0 +1,114 @@ +return { + -- lspconfig + { + "neovim/nvim-lspconfig", + event = "BufReadPre", + dependencies = { + { "folke/neoconf.nvim", cmd = "Neoconf", config = true }, + { "folke/neodev.nvim", config = true }, + "mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + }, + ---@type lspconfig.options + servers = { + jsonls = {}, + sumneko_lua = { + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + completion = { + callSnippet = "Replace", + }, + }, + }, + }, + }, + -- you can do any additional lsp server setup here + -- return true if you don't want this server to be setup with lspconfig + ---@param server string lsp server name + ---@param opts _.lspconfig.options any options set for the server + setup_server = function(server, opts) + return false + end, + + config = function(plugin) + -- setup formatting and keymaps + require("lazy.functions").on_attach(function(client, buffer) + require("lazy.plugins.lsp.format").on_attach(client, buffer) + require("lazy.plugins.lsp.keymaps").on_attach(client, buffer) + end) + + -- diagnostics + for name, icon in pairs(require("lazy.config.icons").diagnostics) do + name = "DiagnosticSign" .. name + vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) + end + vim.diagnostic.config({ + underline = true, + update_in_insert = false, + virtual_text = { spacing = 4, prefix = "●" }, + severity_sort = true, + }) + + ---@type lspconfig.options + local servers = plugin.servers or {} + local capabilities = + require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + + require("mason-lspconfig").setup({ ensure_installed = vim.tbl_keys(servers) }) + require("mason-lspconfig").setup_handlers({ + function(server) + local opts = servers[server] or {} + opts.capabilities = capabilities + if not plugin.setup_server(opts) then + require("lspconfig")[server].setup(opts) + end + end, + }) + end, + }, + + -- formatters + { + "jose-elias-alvarez/null-ls.nvim", + event = "BufReadPre", + dependencies = { "mason.nvim" }, + config = function() + local nls = require("null-ls") + nls.setup({ + sources = { + -- nls.builtins.formatting.prettierd, + nls.builtins.formatting.stylua, + nls.builtins.diagnostics.flake8, + }, + }) + end, + }, + + -- cmdline tools and lsp servers + { + + "williamboman/mason.nvim", + cmd = "Mason", + keys = { { "cm", "Mason", desc = "Mason" } }, + ensure_installed = { + "stylua", + "shellcheck", + "shfmt", + "flake8", + }, + config = function(plugin) + require("mason").setup() + local mr = require("mason-registry") + for _, tool in ipairs(plugin.ensure_installed) do + local p = mr.get_package(tool) + if not p:is_installed() then + p:install() + end + end + end, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/lsp/keymaps.lua b/.config/nvim/lua/lazy/plugins/lsp/keymaps.lua new file mode 100644 index 0000000..32d403f --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/lsp/keymaps.lua @@ -0,0 +1,73 @@ +local M = {} + +function M.on_attach(client, buffer) + local self = M.new(client, buffer) + + self:map("cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) + self:map("cl", "LspInfo", { desc = "Lsp Info" }) + self:map("xd", "Telescope diagnostics", { desc = "Telescope Diagnostics" }) + self:map("gd", "Telescope lsp_definitions", { desc = "Goto Definition" }) + self:map("gr", "Telescope lsp_references", { desc = "References" }) + self:map("gD", "Telescope lsp_declarations", { desc = "Goto Declaration" }) + self:map("gI", "Telescope lsp_implementations", { desc = "Goto Implementation" }) + self:map("gt", "Telescope lsp_type_definitions", { desc = "Goto Type Definition" }) + self:map("K", vim.lsp.buf.hover, { desc = "Hover" }) + self:map("gK", vim.lsp.buf.signature_help, { desc = "Signature Help", has = "signatureHelp" }) + self:map("[d", M.diagnostic_goto(true), { desc = "Next Diagnostic" }) + self:map("]d", M.diagnostic_goto(false), { desc = "Prev Diagnostic" }) + self:map("]e", M.diagnostic_goto(true, "ERROR"), { desc = "Next Error" }) + self:map("[e", M.diagnostic_goto(false, "ERROR"), { desc = "Prev Error" }) + self:map("]w", M.diagnostic_goto(true, "WARNING"), { desc = "Next Warning" }) + self:map("[w", M.diagnostic_goto(false, "WARNING"), { desc = "Prev Warning" }) + self:map("ca", vim.lsp.buf.code_action, { desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }) + + local format = require("lazy.plugins.lsp.format").format + self:map("cf", format, { desc = "Format Document", has = "documentFormatting" }) + self:map("cf", format, { desc = "Format Range", mode = "v", has = "documentRangeFormatting" }) + self:map("cr", M.rename, { expr = true, desc = "Rename", has = "rename" }) + + if client.name == "tsserver" and pcall(require, "typescript") then + self:map("co", "TypescriptOrganizeImports", { desc = "Organize Imports" }) + self:map("cR", "TypescriptRenameFile", { desc = "Rename File" }) + end +end + +function M.new(client, buffer) + return setmetatable({ client = client, buffer = buffer }, { __index = M }) +end + +function M:has(cap) + return self.client.server_capabilities[cap .. "Provider"] +end + +function M:map(lhs, rhs, opts) + opts = opts or {} + if opts.has and not self:has(opts.has) then + return + end + vim.keymap.set( + opts.mode or "n", + lhs, + type(rhs) == "string" and ("%s"):format(rhs) or rhs, + ---@diagnostic disable-next-line: no-unknown + { silent = true, buffer = self.buffer, expr = opts.expr, desc = opts.desc } + ) +end + +function M.rename() + if pcall(require, "inc_rename") then + return ":IncRename " .. vim.fn.expand("") + else + vim.lsp.buf.rename() + end +end + +function M.diagnostic_goto(next, severity) + local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev + severity = severity and vim.diagnostic.severity[severity] or nil + return function() + go({ severity = severity }) + end +end + +return M diff --git a/.config/nvim/lua/lazy/plugins/lualine.lua b/.config/nvim/lua/lazy/plugins/lualine.lua new file mode 100644 index 0000000..89e37dc --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/lualine.lua @@ -0,0 +1,118 @@ +return { + "nvim-lualine/lualine.nvim", + config = function () + local colors = { + red = "#ca1243", + grey = "#a0a1a7", + black = "#383a42", + white = "#f3f3f3", + light_green = "#83a598", + orange = "#fe8019", + green = "#8ec07c", + } + + -- Put proper separators and gaps between components in sections + local function process_sections(sections) + for name, section in pairs(sections) do + local left = name:sub(9, 10) < "x" + for pos = 1, name ~= "lualine_z" and #section or #section - 1 do + table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } }) + end + for id, comp in ipairs(section) do + if type(comp) ~= "table" then + comp = { comp } + section[id] = comp + end + comp.separator = left and { right = "" } or { left = "" } + end + end + return sections + end + + local function search_result() + if vim.v.hlsearch == 0 then + return '' + end + local last_search = vim.fn.getreg('/') + if not last_search or last_search == '' then + return '' + end + local searchcount = vim.fn.searchcount { maxcount = 9999 } + return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')' + -- return "" + end + + local function modified() + if vim.bo.modified then + return "+" + elseif vim.bo.modifiable == false or vim.bo.readonly == true then + return "-" + end + return "" + end + + local status_ok, navic = pcall(require, "nvim-navic") + if not status_ok then + print("navic error!") + return + end + + require("lualine").setup({ + options = { + theme = "gruvbox", + component_separators = "", + section_separators = { left = "", right = "" }, + }, + sections = process_sections({ + lualine_a = { "mode" }, + lualine_b = { + "branch", + "diff", + { + "diagnostics", + source = { "nvim" }, + sections = { "error" }, + diagnostics_color = { error = { bg = colors.red, fg = colors.white } }, + }, + { + "diagnostics", + source = { "nvim" }, + sections = { "warn" }, + diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } }, + }, + { "filename", file_status = false, path = 1 }, + { modified, color = { bg = colors.red } }, + { + "%w", + cond = function() + return vim.wo.previewwindow + end, + }, + { + "%r", + cond = function() + return vim.bo.readonly + end, + }, + { + "%q", + cond = function() + return vim.bo.buftype == "quickfix" + end, + }, + }, + lualine_c = { + { navic.get_location, cond = navic.is_available }, + }, + lualine_x = {}, + -- lualine_y = { search_result, 'filetype' }, + lualine_y = { "filetype " }, + lualine_z = { "%l:%c", "%p%%/%L" }, + }), + inactive_sections = { + lualine_c = { "%f %y %m" }, + lualine_x = {}, + }, + }) + end, +} diff --git a/.config/nvim/lua/lazy/plugins/noice.lua b/.config/nvim/lua/lazy/plugins/noice.lua new file mode 100644 index 0000000..d2b2a3f --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/noice.lua @@ -0,0 +1,28 @@ +return { + { + "folke/noice.nvim", + event = "VeryLazy", + config = { + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + }, + }, + presets = { + bottom_search = true, + command_palette = true, + long_message_to_split = true, + }, + }, + -- stylua: ignore + keys = { + { "", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" }, + { "nl", function() require("noice").cmd("last") end, desc = "Noice Last Message" }, + { "nh", function() require("noice").cmd("history") end, desc = "Noice History" }, + { "na", function() require("noice").cmd("all") end, desc = "Noice All" }, + { "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true }, + { "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true }, + }, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/snippets.lua b/.config/nvim/lua/lazy/plugins/snippets.lua new file mode 100644 index 0000000..7e7d1c2 --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/snippets.lua @@ -0,0 +1,30 @@ +return { + { + "L3MON4D3/LuaSnip", + dependencies = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + config = { + history = true, + delete_check_events = "TextChanged", + }, + -- stylua: ignore + keys = { + { + "", + function() + return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" + end, + expr = true, remap = true, silent = true, mode = "i", + }, + { "", function() require("luasnip").jump(1) end, mode = "s" }, + { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, + }, + }, + { + "rafamadriz/friendly-snippets", -- collection of useful snippets + }, +} diff --git a/.config/nvim/lua/lazy/plugins/starter.lua b/.config/nvim/lua/lazy/plugins/starter.lua new file mode 100644 index 0000000..bb48c10 --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/starter.lua @@ -0,0 +1,66 @@ +return { +{ + "echasnovski/mini.starter", + enabled = false, + version = false, -- wait till new 0.7.0 release to put it back on semver + event = "VimEnter", + config = function() + local logo = table.concat({ + "██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z", + "██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z", + "██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z", + "██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z", + "███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║", + "╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝", + }, "\n") + local pad = string.rep(" ", 22) + local new_section = function(name, action, section) + return { name = name, action = action, section = pad .. section } + end + + local starter = require("mini.starter") + --stylua: ignore + local config = { + evaluate_single = true, + header = logo, + items = { + new_section("Find file", "Telescope find_files", "Telescope"), + new_section("Recent files", "Telescope oldfiles", "Telescope"), + new_section("Grep text", "Telescope live_grep", "Telescope"), + new_section("init.lua", "e $MYVIMRC", "Config"), + new_section("Lazy", "Lazy", "Config"), + new_section("New file", "ene | startinsert", "Built-in"), + new_section("Quit", "qa", "Built-in"), + }, + content_hooks = { + starter.gen_hook.adding_bullet(pad .. "░ ", false), + starter.gen_hook.aligning("center", "center"), + }, + } + + -- close Lazy and re-open when starter is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + pattern = "MiniStarterOpened", + callback = function() + require("lazy").show() + end, + }) + end + + starter.setup(config) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + callback = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + local pad_footer = string.rep(" ", 8) + MiniStarter.config.footer = pad_footer .. "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" + pcall(MiniStarter.refresh) + end, + }) + end, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/treesitter.lua b/.config/nvim/lua/lazy/plugins/treesitter.lua new file mode 100644 index 0000000..b355e2b --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/treesitter.lua @@ -0,0 +1,19 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "BufReadPost", + ensure_installed = "all", + config = function(plugin) + require("nvim-treesitter.configs").setup({ + sync_install = false, + ensure_installed = plugin.ensure_installed, + matchup = { enable = true }, + highlight = { enable = true }, + autopairs = { enable = true }, + indent = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = false }, + }) + end, + }, +} diff --git a/.config/nvim/lua/lazy/plugins/utility.lua b/.config/nvim/lua/lazy/plugins/utility.lua new file mode 100644 index 0000000..188bd67 --- /dev/null +++ b/.config/nvim/lua/lazy/plugins/utility.lua @@ -0,0 +1,274 @@ +return { + { + "nvim-lua/plenary.nvim", + }, + { + "nvim-lua/popup.nvim", + }, + { + "folke/neodev.nvim", + }, + { + "rcarriga/nvim-notify", + config = function() + local icons = require "user.icons" + require"notify".setup { + -- Animation style (see below for details) + stages = "fade_in_slide_out", + + -- Function called when a new window is opened, use for changing win settings/config + on_open = nil, + + -- Function called when a window is closed + on_close = nil, + + -- Render function for notifications. See notify-render() + render = "default", + + -- Default timeout for notifications + timeout = 2000, + + -- For stages that change opacity this is treated as the highlight behind the window + -- Set this to either a highlight group or an RGB hex value e.g. "#000000" + background_colour = "Normal", + + -- Minimum width for notification windows + minimum_width = 10, + + -- Icons for the different levels + icons = { + ERROR = icons.diagnostics.Error, + WARN = icons.diagnostics.Warning, + INFO = icons.diagnostics.Information, + DEBUG = icons.ui.Bug, + TRACE = icons.ui.Pencil, + }, + } + end, + }, + { + "moll/vim-bbye", + }, + { + "lewis6991/impatient.nvim", + config = function() + require"impatient".enable_profile() + end, + }, + { + "ghillb/cybu.nvim", + config = function() + require"cybu".setup({ + position = { + relative_to = "win", -- win, editor, cursor + anchor = "topright", -- topleft, topcenter, topright, + -- centerleft, center, centerright, + -- bottomleft, bottomcenter, bottomright + -- vertical_offset = 10, -- vertical offset from anchor in lines + -- horizontal_offset = 0, -- vertical offset from anchor in columns + -- max_win_height = 5, -- height of cybu window in lines + -- max_win_width = 0.5, -- integer for absolute in columns + -- float for relative to win/editor width + }, + display_time = 1750, -- time the cybu window is displayed + style = { + separator = " ", -- string used as separator + prefix = "…", -- string used as prefix for truncated paths + padding = 1, -- left & right padding in number of spaces + hide_buffer_id = true, + devicons = { + enabled = true, -- enable or disable web dev icons + colored = true, -- enable color for web dev icons + }, + }, + }) + end, + }, + { + "mbbill/undotree", + }, + { + "MunifTanjim/nui.nvim", + }, + { + "kyazdani42/nvim-web-devicons" + }, + { + "lukas-reineke/indent-blankline.nvim", + config = function() + vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" } + vim.g.indent_blankline_filetype_exclude = { + "help", + "startify", + "dashboard", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", + "text" + } + vim.g.indentLine_enabled = 1 + vim.g.indent_blankline_char = "▏" + + vim.g.indent_blankline_show_trailing_blankline_indent = false + vim.g.indent_blankline_show_first_indent_level = true + vim.g.indent_blankline_use_treesitter = false + vim.g.indent_blankline_show_current_context = true + + require"indent_blankline".setup({ + show_current_context = true, + }) + end, + }, + { + "windwp/nvim-autopairs", + config = function() + require"nvim-autopairs".setup({ + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + ignore_next_char = "[%w%.*]", -- don't place pair when cursor sits in front of any char + }) + end, + }, + { + "preservim/vim-markdown", + }, + { + "nacro90/numb.nvim", + config = function() + require"numb".setup({ + show_numbers = true, -- enable 'number' for the window while peeking + show_cursorline = true, -- enable 'cursorline' for window wdile peeking + }) + end, + }, + { + "andymass/vim-matchup", + }, + { + "junegunn/vim-slash", + }, + { + "folke/zen-mode.nvim", + config = function() + require"zen-mode".setup({ + window = { + backdrop = 1, + height = 0.9, + width = 80, + options = { + signcolumn = "no", + number = false, + relativenumber = false, + cursorline = true, + cursorcolumn = false, -- disable cursor column + }, + }, + plugins = { + gitsigns = { enabled = false }, + tmux = { enabled = false }, + twilight = { enabled = false }, + }, + on_open = function() + vim.g.cmp_active = false + vim.cmd [[LspStop]] + local status_ok, _ = pcall(vim.api.nvim_set_option_value, "winbar", nil, { scope = "local" }) + if not status_ok then + return + end + if vim.fn.exists("#" .. "_winbar") == 1 then + vim.cmd("au! " .. "_winbar") + end + end, + on_close = function() + vim.g.cmp_active = true + vim.cmd [[LspStart]] + require("user.winbar").create_winbar() + end, + }) + end, + }, + { + "tpope/vim-surround", + }, + { + "danymat/neogen", + config = function() + require"neogen".setup({ + enabled = true, + input_after_comment = true, + }) + end, + }, + { + "monaqa/dial.nvim", + config = function() + local dial_config = require"dial.config" + + local y = "2024/05/29" + + local augend = require "dial.augend" + dial_config.augends:register_group { + default = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.date.alias["%Y/%m/%d"], + }, + typescript = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.constant.new { elements = { "let", "const" } }, + }, + visual = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.date.alias["%Y/%m/%d"], + augend.constant.alias.alpha, + augend.constant.alias.Alpha, + }, + mygroup = { + augend.constant.new { + elements = { "and", "or" }, + word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. + cyclic = true, -- "or" is incremented into "and". + }, + augend.constant.new { + elements = { "True", "False" }, + word = true, + cyclic = true, + }, + augend.constant.new { + elements = { "public", "private" }, + word = true, + cyclic = true, + }, + augend.constant.new { + elements = { "&&", "||" }, + word = false, + cyclic = true, + }, + augend.date.alias["%d/%m/%Y"], -- date (02/19/2022, etc.) + augend.constant.alias.bool, -- boolean value (true <-> false) + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.semver.alias.semver + }, + } + + local map = require "dial.map" + + -- change augends in VISUAL mode + vim.api.nvim_set_keymap("n", "", map.inc_normal "mygroup", { noremap = true }) + vim.api.nvim_set_keymap("n", "", map.dec_normal "mygroup", { noremap = true }) + vim.api.nvim_set_keymap("v", "", map.inc_normal "visual", { noremap = true }) + vim.api.nvim_set_keymap("v", "", map.dec_normal "visual", { noremap = true }) + + vim.cmd [[ + " enable only for specific FileType + autocmd FileType typescript,javascript lua vim.api.nvim_buf_set_keymap(0, "n", "", require("dial.map").inc_normal("typescript"), {noremap = true}) + ]] + end, + }, + { + "ThePrimeagen/harpoon", + }, +}