From 86cf2fa9d4f925f0ba8d03969328d64e1e324abc Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Sat, 26 Jul 2025 18:40:23 +0200 Subject: [PATCH] (neovim) move coding related components to extra loaded configuration --- config/common/nvim/init.lua | 6 ++ config/common/nvim/lsp/lua.lua | 3 +- .../config}/global.markdownlint-cli2.yaml | 0 config/common/nvim/lua/config/keymaps.lua | 8 --- config/common/nvim/lua/core/lazy.lua | 6 +- .../lua/plugins/{ => common}/colorizer.lua | 0 .../lua/plugins/{ => common}/gitsigns.lua | 0 .../nvim/lua/plugins/common/lualine.lua | 64 +++++++++++++++++++ .../lua/plugins/{ => common}/markdown.lua | 0 .../plugins/{mini.lua => common/monokai.lua} | 18 ++++++ .../nvim/lua/plugins/{ => common}/noice.lua | 0 .../nvim/lua/plugins/{ => common}/snacks.lua | 0 .../nvim/lua/plugins/common/treesitter.lua | 37 +++++++++++ .../nvim/lua/plugins/common/which-key.lua | 52 +++++++++++++++ .../nvim/lua/plugins/{ => extra}/ansible.lua | 0 .../nvim/lua/plugins/{ => extra}/blink.lua | 0 .../nvim/lua/plugins/{ => extra}/linters.lua | 2 +- config/common/nvim/lua/plugins/lualine.lua | 61 ------------------ config/common/nvim/lua/plugins/monokai.lua | 14 ---- config/common/nvim/lua/plugins/treesitter.lua | 32 ---------- config/common/nvim/lua/plugins/which-key.lua | 38 ----------- 21 files changed, 185 insertions(+), 156 deletions(-) rename config/common/nvim/{cfg_linters => lua/config}/global.markdownlint-cli2.yaml (100%) rename config/common/nvim/lua/plugins/{ => common}/colorizer.lua (100%) rename config/common/nvim/lua/plugins/{ => common}/gitsigns.lua (100%) create mode 100644 config/common/nvim/lua/plugins/common/lualine.lua rename config/common/nvim/lua/plugins/{ => common}/markdown.lua (100%) rename config/common/nvim/lua/plugins/{mini.lua => common/monokai.lua} (51%) rename config/common/nvim/lua/plugins/{ => common}/noice.lua (100%) rename config/common/nvim/lua/plugins/{ => common}/snacks.lua (100%) create mode 100644 config/common/nvim/lua/plugins/common/treesitter.lua create mode 100644 config/common/nvim/lua/plugins/common/which-key.lua rename config/common/nvim/lua/plugins/{ => extra}/ansible.lua (100%) rename config/common/nvim/lua/plugins/{ => extra}/blink.lua (100%) rename config/common/nvim/lua/plugins/{ => extra}/linters.lua (97%) delete mode 100644 config/common/nvim/lua/plugins/lualine.lua delete mode 100644 config/common/nvim/lua/plugins/monokai.lua delete mode 100644 config/common/nvim/lua/plugins/treesitter.lua delete mode 100644 config/common/nvim/lua/plugins/which-key.lua diff --git a/config/common/nvim/init.lua b/config/common/nvim/init.lua index f6daed1..94a46f1 100644 --- a/config/common/nvim/init.lua +++ b/config/common/nvim/init.lua @@ -1,2 +1,8 @@ +if os.getenv("NVIM_MAIN_HOST") then + MainHost = true +else + MainHost = false +end + require("config") require("core") diff --git a/config/common/nvim/lsp/lua.lua b/config/common/nvim/lsp/lua.lua index 42d872d..2a80c7e 100644 --- a/config/common/nvim/lsp/lua.lua +++ b/config/common/nvim/lsp/lua.lua @@ -5,8 +5,9 @@ return { Lua = { diagnostics = { globals = { - "vim", + "MainHost", "Snacks", + "vim", }, }, }, diff --git a/config/common/nvim/cfg_linters/global.markdownlint-cli2.yaml b/config/common/nvim/lua/config/global.markdownlint-cli2.yaml similarity index 100% rename from config/common/nvim/cfg_linters/global.markdownlint-cli2.yaml rename to config/common/nvim/lua/config/global.markdownlint-cli2.yaml diff --git a/config/common/nvim/lua/config/keymaps.lua b/config/common/nvim/lua/config/keymaps.lua index 7516364..6bf7d2c 100644 --- a/config/common/nvim/lua/config/keymaps.lua +++ b/config/common/nvim/lua/config/keymaps.lua @@ -54,14 +54,6 @@ map("n", "bl", function() end, { desc = "buffer list", remap = true }) map("n", "bn", "enew", { desc = "buffer create", remap = true }) -map("n", "cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) -map({ "n", "v" }, "cf", function() - require("conform").format({ - lsp_fallback = true, - async = false, - }) -end, { desc = "format", remap = true }) - map("n", "e", function() Snacks.explorer() end, { desc = "explorer", remap = true }) diff --git a/config/common/nvim/lua/core/lazy.lua b/config/common/nvim/lua/core/lazy.lua index 82c65e6..b4828aa 100644 --- a/config/common/nvim/lua/core/lazy.lua +++ b/config/common/nvim/lua/core/lazy.lua @@ -16,7 +16,11 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup({ spec = { - { import = "plugins" }, + { import = "plugins.common" }, + { + import = "plugins.extra", + cond = MainHost, + }, }, defaults = { lazy = true, diff --git a/config/common/nvim/lua/plugins/colorizer.lua b/config/common/nvim/lua/plugins/common/colorizer.lua similarity index 100% rename from config/common/nvim/lua/plugins/colorizer.lua rename to config/common/nvim/lua/plugins/common/colorizer.lua diff --git a/config/common/nvim/lua/plugins/gitsigns.lua b/config/common/nvim/lua/plugins/common/gitsigns.lua similarity index 100% rename from config/common/nvim/lua/plugins/gitsigns.lua rename to config/common/nvim/lua/plugins/common/gitsigns.lua diff --git a/config/common/nvim/lua/plugins/common/lualine.lua b/config/common/nvim/lua/plugins/common/lualine.lua new file mode 100644 index 0000000..4fd075e --- /dev/null +++ b/config/common/nvim/lua/plugins/common/lualine.lua @@ -0,0 +1,64 @@ +local lualine_sections = { + lualine_a = { "mode" }, + lualine_b = { + { "branch" }, + { + "diff", + symbols = { + added = " ", + modified = " ", + removed = " ", + }, + }, + }, + lualine_c = { + { "filename", file_status = true, path = 1 }, + }, + lualine_x = {}, + lualine_y = { + { "searchcount" }, + { "progress", padding = { left = 1, right = 0 }, separator = " " }, + { "location", padding = { left = 0, right = 1 } }, + }, + lualine_z = {}, +} + +if MainHost then + table.insert(lualine_sections.lualine_x, { + "diagnostics", + symbols = { + error = " ", + warn = " ", + info = " ", + hint = " ", + }, + }) + table.insert(lualine_sections.lualine_x, { + "lsp_status", + symbols = { + spinner = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }, + done = "✓", + separator = " ", + }, + }) +end + +return { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + config = function() + require("lualine").setup({ + options = { + theme = "powerline", + section_separators = "", + component_separators = "", + globalstatus = false, + disabled_filetypes = { statusline = { "snacks_dashboard" } }, + }, + sections = lualine_sections, + tabline = { + lualine_a = { "buffers" }, + }, + }) + end, +} diff --git a/config/common/nvim/lua/plugins/markdown.lua b/config/common/nvim/lua/plugins/common/markdown.lua similarity index 100% rename from config/common/nvim/lua/plugins/markdown.lua rename to config/common/nvim/lua/plugins/common/markdown.lua diff --git a/config/common/nvim/lua/plugins/mini.lua b/config/common/nvim/lua/plugins/common/monokai.lua similarity index 51% rename from config/common/nvim/lua/plugins/mini.lua rename to config/common/nvim/lua/plugins/common/monokai.lua index cfdb377..fc76e72 100644 --- a/config/common/nvim/lua/plugins/mini.lua +++ b/config/common/nvim/lua/plugins/common/monokai.lua @@ -1,4 +1,5 @@ return { + { "echasnovski/mini.pairs", event = "VeryLazy", config = function() @@ -10,4 +11,21 @@ return { markdown = true, }) end, + + }, + { + "loctvl842/monokai-pro.nvim", + priority = 10000, + lazy = false, + dependencies = { + "echasnovski/mini.icons", + "echasnovski/mini.pairs", + }, + config = function() + require("monokai-pro").setup({ + filter = "classic", + }) + vim.cmd.colorscheme("monokai-pro") + end, + } } diff --git a/config/common/nvim/lua/plugins/noice.lua b/config/common/nvim/lua/plugins/common/noice.lua similarity index 100% rename from config/common/nvim/lua/plugins/noice.lua rename to config/common/nvim/lua/plugins/common/noice.lua diff --git a/config/common/nvim/lua/plugins/snacks.lua b/config/common/nvim/lua/plugins/common/snacks.lua similarity index 100% rename from config/common/nvim/lua/plugins/snacks.lua rename to config/common/nvim/lua/plugins/common/snacks.lua diff --git a/config/common/nvim/lua/plugins/common/treesitter.lua b/config/common/nvim/lua/plugins/common/treesitter.lua new file mode 100644 index 0000000..363cfab --- /dev/null +++ b/config/common/nvim/lua/plugins/common/treesitter.lua @@ -0,0 +1,37 @@ +local treesitter_modules = { + "bash", + "markdown_inline", + "markdown", +} + +if MainHost then + vim.list_extend(treesitter_modules, { + "git_config", + "git_rebase", + "gitattributes", + "gitcommit", + "gitignore", + "gotmpl", + "hcl", + "helm", + "json", + "lua", + "python", + "regex", + "terraform", + "yaml", + }) +end + +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "VeryLazy", + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = treesitter_modules, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, +} diff --git a/config/common/nvim/lua/plugins/common/which-key.lua b/config/common/nvim/lua/plugins/common/which-key.lua new file mode 100644 index 0000000..4cb1394 --- /dev/null +++ b/config/common/nvim/lua/plugins/common/which-key.lua @@ -0,0 +1,52 @@ +local whichkey_spec = { + mode = { "n", "v" }, + { "b", group = "buffer" }, + { "f", group = "find" }, + { "h", group = "history" }, + { "u", group = "ui" }, +} + +if MainHost then + vim.list_extend(whichkey_spec, { + { "c", group = "code" }, + { "cd", vim.diagnostic.open_float, { desc = "diagnostics", remap = true } }, + { + "cf", + function() + require("conform").format({ + lsp_fallback = true, + async = false, + }) + end, + { desc = "format", remap = true }, + }, + }) +end + +return { + "folke/which-key.nvim", + event = "VeryLazy", + config = function() + require("which-key").setup({ + preset = "helix", + delay = 300, + icons = { + rules = false, + breadcrumb = " ", + separator = "󱦰 ", + group = "󰹍 ", + }, + plugins = { + spelling = { + enabled = false, + }, + }, + win = { + height = { + max = math.huge, + }, + }, + spec = whichkey_spec, + }) + end, +} diff --git a/config/common/nvim/lua/plugins/ansible.lua b/config/common/nvim/lua/plugins/extra/ansible.lua similarity index 100% rename from config/common/nvim/lua/plugins/ansible.lua rename to config/common/nvim/lua/plugins/extra/ansible.lua diff --git a/config/common/nvim/lua/plugins/blink.lua b/config/common/nvim/lua/plugins/extra/blink.lua similarity index 100% rename from config/common/nvim/lua/plugins/blink.lua rename to config/common/nvim/lua/plugins/extra/blink.lua diff --git a/config/common/nvim/lua/plugins/linters.lua b/config/common/nvim/lua/plugins/extra/linters.lua similarity index 97% rename from config/common/nvim/lua/plugins/linters.lua rename to config/common/nvim/lua/plugins/extra/linters.lua index d4b261c..2b72e89 100644 --- a/config/common/nvim/lua/plugins/linters.lua +++ b/config/common/nvim/lua/plugins/extra/linters.lua @@ -64,7 +64,7 @@ return { local markdownlint = require("lint").linters["markdownlint-cli2"] markdownlint.args = { "--config", - vim.fn.stdpath("config") .. "/cfg_linters/global.markdownlint-cli2.yaml", + vim.fn.stdpath("config") .. "/lua/config/global.markdownlint-cli2.yaml", } vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { diff --git a/config/common/nvim/lua/plugins/lualine.lua b/config/common/nvim/lua/plugins/lualine.lua deleted file mode 100644 index ba9110f..0000000 --- a/config/common/nvim/lua/plugins/lualine.lua +++ /dev/null @@ -1,61 +0,0 @@ -return { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - config = function() - require("lualine").setup({ - options = { - theme = "powerline", - section_separators = "", - component_separators = "", - globalstatus = false, - disabled_filetypes = { statusline = { "snacks_dashboard" } }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { - { "branch" }, - { - "diff", - symbols = { - added = " ", - modified = " ", - removed = " ", - }, - }, - { - "diagnostics", - symbols = { - error = " ", - warn = " ", - info = " ", - hint = " ", - }, - }, - }, - lualine_c = { - { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { "filename", file_status = true, path = 1 }, - }, - lualine_x = { - { - "lsp_status", - symbols = { - spinner = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }, - done = "✓", - separator = " ", - }, - }, - }, - lualine_y = { - { "searchcount" }, - { "progress", separator = " ", padding = { left = 1, right = 0 } }, - { "location", padding = { left = 0, right = 1 } }, - }, - lualine_z = {}, - }, - tabline = { - lualine_a = { "buffers" }, - }, - }) - end, -} diff --git a/config/common/nvim/lua/plugins/monokai.lua b/config/common/nvim/lua/plugins/monokai.lua deleted file mode 100644 index 6d2b649..0000000 --- a/config/common/nvim/lua/plugins/monokai.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - "loctvl842/monokai-pro.nvim", - priority = 10000, - lazy = false, - dependencies = { - "echasnovski/mini.icons", - }, - config = function() - require("monokai-pro").setup({ - filter = "classic", - }) - vim.cmd.colorscheme("monokai-pro") - end, -} diff --git a/config/common/nvim/lua/plugins/treesitter.lua b/config/common/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index 5099497..0000000 --- a/config/common/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = "VeryLazy", - config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "bash", - "diff", - "git_config", - "git_rebase", - "gitattributes", - "gitcommit", - "gitignore", - "gotmpl", - "hcl", - "helm", - "json", - "lua", - "markdown_inline", - "markdown", - "python", - "regex", - "terraform", - "vim", - "yaml", - }, - highlight = { enable = true }, - indent = { enable = true }, - }) - end, -} diff --git a/config/common/nvim/lua/plugins/which-key.lua b/config/common/nvim/lua/plugins/which-key.lua deleted file mode 100644 index 97ac0dd..0000000 --- a/config/common/nvim/lua/plugins/which-key.lua +++ /dev/null @@ -1,38 +0,0 @@ -return { - "folke/which-key.nvim", - event = "VeryLazy", - config = function() - require("which-key").setup({ - preset = "helix", - delay = 300, - icons = { - rules = false, - breadcrumb = " ", - separator = "󱦰 ", - group = "󰹍 ", - }, - plugins = { - spelling = { - enabled = false, - }, - }, - win = { - height = { - max = math.huge, - }, - }, - spec = { - { - mode = { "n", "v" }, - { "[", group = "previous..." }, - { "]", group = "next..." }, - { "b", group = "buffer" }, - { "c", group = "code" }, - { "f", group = "find" }, - { "h", group = "history" }, - { "u", group = "ui" }, - }, - }, - }) - end, -}