From adbc5ac6068ca41d4b408461a9298a07f3da13ed Mon Sep 17 00:00:00 2001 From: user Date: Mon, 7 Sep 2026 22:38:38 +0400 Subject: [PATCH] feat(nvim): add LazyVim-based configuration --- nvim/.config/nvim/.gitignore | 8 ++ nvim/.config/nvim/.neoconf.json | 15 +++ nvim/.config/nvim/init.lua | 11 ++ nvim/.config/nvim/lazy-lock.json | 56 +++++++++ nvim/.config/nvim/lazyvim.json | 13 ++ nvim/.config/nvim/lua/config/autocmds.lua | 8 ++ nvim/.config/nvim/lua/config/keymaps.lua | 5 + nvim/.config/nvim/lua/config/lazy.lua | 100 +++++++++++++++ nvim/.config/nvim/lua/config/options.lua | 16 +++ nvim/.config/nvim/lua/plugins/diffview.lua | 90 +++++++++++++ .../nvim/lua/plugins/languages/clang.lua | 67 ++++++++++ .../nvim/lua/plugins/languages/java.lua | 119 ++++++++++++++++++ .../nvim/lua/plugins/languages/json.lua | 34 +++++ .../nvim/lua/plugins/languages/plantuml.lua | 23 ++++ .../nvim/lua/plugins/languages/xml.lua | 28 +++++ nvim/.config/nvim/lua/utils/scanner.lua | 85 +++++++++++++ nvim/.config/nvim/stylua.toml | 3 + 17 files changed, 681 insertions(+) create mode 100644 nvim/.config/nvim/.gitignore create mode 100644 nvim/.config/nvim/.neoconf.json create mode 100644 nvim/.config/nvim/init.lua create mode 100644 nvim/.config/nvim/lazy-lock.json create mode 100644 nvim/.config/nvim/lazyvim.json create mode 100644 nvim/.config/nvim/lua/config/autocmds.lua create mode 100644 nvim/.config/nvim/lua/config/keymaps.lua create mode 100644 nvim/.config/nvim/lua/config/lazy.lua create mode 100644 nvim/.config/nvim/lua/config/options.lua create mode 100644 nvim/.config/nvim/lua/plugins/diffview.lua create mode 100644 nvim/.config/nvim/lua/plugins/languages/clang.lua create mode 100644 nvim/.config/nvim/lua/plugins/languages/java.lua create mode 100644 nvim/.config/nvim/lua/plugins/languages/json.lua create mode 100644 nvim/.config/nvim/lua/plugins/languages/plantuml.lua create mode 100644 nvim/.config/nvim/lua/plugins/languages/xml.lua create mode 100644 nvim/.config/nvim/lua/utils/scanner.lua create mode 100644 nvim/.config/nvim/stylua.toml diff --git a/nvim/.config/nvim/.gitignore b/nvim/.config/nvim/.gitignore new file mode 100644 index 0000000..cc5457a --- /dev/null +++ b/nvim/.config/nvim/.gitignore @@ -0,0 +1,8 @@ +tt.* +.tests +doc/tags +debug +.repro +foo.* +*.log +data diff --git a/nvim/.config/nvim/.neoconf.json b/nvim/.config/nvim/.neoconf.json new file mode 100644 index 0000000..7c48087 --- /dev/null +++ b/nvim/.config/nvim/.neoconf.json @@ -0,0 +1,15 @@ +{ + "neodev": { + "library": { + "enabled": true, + "plugins": true + } + }, + "neoconf": { + "plugins": { + "lua_ls": { + "enabled": true + } + } + } +} diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..b7fb75f --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,11 @@ +-- bootstrap lazy.nvim, LazyVim and your plugins +require("config.lazy") + +-- Associate .puml files with plantuml filetype +vim.filetype.add({ + extension = { + puml = "plantuml", + }, +}) + +-- vim.g.plugins_debug = true diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..093e5e4 --- /dev/null +++ b/nvim/.config/nvim/lazy-lock.json @@ -0,0 +1,56 @@ +{ + "LazyVim": { "branch": "main", "commit": "c10948c50b18fae7f256433afdef09e432410480" }, + "SchemaStore.nvim": { "branch": "main", "commit": "3d2c297f7152208daf4a382ea7123f9e4ebf9da1" }, + "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "catppuccin": { "branch": "main", "commit": "79e2049a0fdf7ec840f8463fe1d962c94493196b" }, + "clangd_extensions.nvim": { "branch": "main", "commit": "78c2ecd659d54972be17aa6ba2deac3c53223b80" }, + "cmake-tools.nvim": { "branch": "master", "commit": "22859d754b5de738cfe9945e0910729f63deefd0" }, + "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, + "crates.nvim": { "branch": "main", "commit": "694357861ec9ebf12475ddcdd04ea45a0923c32d" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "flash.nvim": { "branch": "main", "commit": "b6346946d10d07998efee029fb0f7a593806d0cd" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, + "gitsigns.nvim": { "branch": "main", "commit": "31d6fb2d618bca1482b9f274751ead5f03461408" }, + "grug-far.nvim": { "branch": "main", "commit": "0f6a5d0d7a70659b11bbcd6b3673ee0fe61b6024" }, + "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, + "lazydev.nvim": { "branch": "main", "commit": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d" }, + "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "7adc933dabcc7c86ae6b07aff7ee68eac398491f" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, + "mini.ai": { "branch": "main", "commit": "25248c6aa002391936a6200f12d1466015987133" }, + "mini.icons": { "branch": "main", "commit": "98faae31e9be1cc054ae63485e58ceb185efcad0" }, + "mini.pairs": { "branch": "main", "commit": "b1c5a726921b7a8c9321e9a7a208aa0571de5810" }, + "mini.surround": { "branch": "main", "commit": "8d5d0c5aa92449368ac251e85451d79d8f69d296" }, + "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-dap": { "branch": "master", "commit": "9e848e09a697ee95302a3ef2dd43fd6eb709e570" }, + "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, + "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, + "nvim-dap-ui": { "branch": "master", "commit": "cc9dd33aade7f20bae414d0cba163bc60d4d4b43" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-jdtls": { "branch": "master", "commit": "6e9d953f0b82bccdb834cfde0e893f3119c22592" }, + "nvim-lint": { "branch": "master", "commit": "a219b2c9e5b4765e5c845aba119dad55806fcaf1" }, + "nvim-lspconfig": { "branch": "master", "commit": "d592c1e6ad9a0a01b3d5ed3f0345d68407167181" }, + "nvim-nio": { "branch": "master", "commit": "edcc181a875301dd21840189aa2f2f9ad69fc172" }, + "nvim-treesitter": { "branch": "main", "commit": "8b3a191c015dd66a92d51a112ed96af0aac13b63" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "898ee307df58f854d11cd7edd06472574d48014e" }, + "nvim-ts-autotag": { "branch": "main", "commit": "88c1453db4ba7dd24131086fe51fdf74e587d275" }, + "omnisharp-extended-lsp.nvim": { "branch": "main", "commit": "51e407a46ddb15e49727139b5b1ae3650cd6a069" }, + "open-browser.vim": { "branch": "master", "commit": "7d4c1d8198e889d513a030b5a83faa07606bac27" }, + "persistence.nvim": { "branch": "main", "commit": "b20b2a7887bd39c1a356980b45e03250f3dce49c" }, + "plantuml-previewer.vim": { "branch": "master", "commit": "368a1f331c1ff29f6a3ee76facfca39a7f374b13" }, + "plantuml-syntax": { "branch": "master", "commit": "9d4900aa16674bf5bb8296a72b975317d573b547" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "render-markdown.nvim": { "branch": "main", "commit": "f422cb5c6855f150e2ddcfaf44e7157b98b34f6a" }, + "rustaceanvim": { "branch": "main", "commit": "32969563686a262ef91161b54a1cac66b2d5a766" }, + "snacks.nvim": { "branch": "main", "commit": "882c996cf28183f4d63640de0b4c02ec886d01f2" }, + "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, + "tokyonight.nvim": { "branch": "main", "commit": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6" }, + "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, + "ts-comments.nvim": { "branch": "main", "commit": "a59d6092213447450191122c9346f309161504cb" }, + "venv-selector.nvim": { "branch": "main", "commit": "cc4bb3975de8835291f9bb45889e96c6b2795fc4" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/nvim/.config/nvim/lazyvim.json b/nvim/.config/nvim/lazyvim.json new file mode 100644 index 0000000..cd86240 --- /dev/null +++ b/nvim/.config/nvim/lazyvim.json @@ -0,0 +1,13 @@ +{ + "extras": [ + "lazyvim.plugins.extras.coding.mini-surround", + "lazyvim.plugins.extras.lang.cmake", + "lazyvim.plugins.extras.lang.git", + "lazyvim.plugins.extras.lang.java" + ], + "install_version": 8, + "news": { + "NEWS.md": "11866" + }, + "version": 8 +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/config/autocmds.lua b/nvim/.config/nvim/lua/config/autocmds.lua new file mode 100644 index 0000000..4221e75 --- /dev/null +++ b/nvim/.config/nvim/lua/config/autocmds.lua @@ -0,0 +1,8 @@ +-- Autocmds are automatically loaded on the VeryLazy event +-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua +-- +-- Add any additional autocmds here +-- with `vim.api.nvim_create_autocmd` +-- +-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults) +-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell") diff --git a/nvim/.config/nvim/lua/config/keymaps.lua b/nvim/.config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..b0f063a --- /dev/null +++ b/nvim/.config/nvim/lua/config/keymaps.lua @@ -0,0 +1,5 @@ +-- Keymaps are automatically loaded on the VeryLazy event +-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua +-- Add any additional keymaps here + +Snacks.toggle.option("list", { name = "Invisible chars" }):map("uv") diff --git a/nvim/.config/nvim/lua/config/lazy.lua b/nvim/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..6a6979b --- /dev/null +++ b/nvim/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,100 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" + +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + + local out = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + lazyrepo, + lazypath, + }) + + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + + vim.fn.getchar() + os.exit(1) + end +end + +vim.opt.rtp:prepend(lazypath) + +-- Import all custom plugins recursively +local plugin_specs = require("utils.scanner").scan("plugins") + +if vim.g.plugins_debug then + vim.notify(string.format("[plugins] Found %d import(s)", #plugin_specs), vim.log.levels.INFO) + for i, spec in ipairs(plugin_specs) do + vim.notify(string.format("[plugins] %d. %s", i, spec.import), vim.log.levels.INFO) + end +end + +require("lazy").setup({ + spec = { + -- add LazyVim and import its plugins + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + + -- LazyVim extras would go here + { import = "lazyvim.plugins.extras.dap.core" }, + { import = "lazyvim.plugins.extras.lang.clangd" }, + { import = "lazyvim.plugins.extras.lang.cmake" }, + { import = "lazyvim.plugins.extras.lang.docker" }, + { import = "lazyvim.plugins.extras.lang.dotnet" }, + { import = "lazyvim.plugins.extras.lang.git" }, + { import = "lazyvim.plugins.extras.lang.go" }, + { import = "lazyvim.plugins.extras.lang.java" }, + { import = "lazyvim.plugins.extras.lang.json" }, + { import = "lazyvim.plugins.extras.lang.markdown" }, + { import = "lazyvim.plugins.extras.lang.python" }, + { import = "lazyvim.plugins.extras.lang.rust" }, + { import = "lazyvim.plugins.extras.lang.toml" }, + { import = "lazyvim.plugins.extras.lang.typescript" }, + { import = "lazyvim.plugins.extras.lang.yaml" }, + + -- Your own plugins must be last + unpack(plugin_specs), + }, + + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. + -- Your custom plugins will load during startup. + lazy = false, + + -- It's recommended to leave version=false for now. + version = false, + }, + + install = { + colorscheme = { + "tokyonight", + "habamax", + }, + }, + + checker = { + enabled = true, + notify = false, + }, + + performance = { + rtp = { + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/nvim/.config/nvim/lua/config/options.lua b/nvim/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..11ddf32 --- /dev/null +++ b/nvim/.config/nvim/lua/config/options.lua @@ -0,0 +1,16 @@ +-- Options are automatically loaded before lazy.nvim startup +-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua +-- Add any additional options here +-- +vim.opt.list = true + +vim.opt.listchars = { + tab = "→ ", + trail = "·", + nbsp = "␣", + space = "·", +} + +vim.opt.encoding = "utf-8" +vim.opt.fileencoding = "utf-8" +vim.opt.fileencodings = "utf-8,latin1" diff --git a/nvim/.config/nvim/lua/plugins/diffview.lua b/nvim/.config/nvim/lua/plugins/diffview.lua new file mode 100644 index 0000000..ee1b560 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/diffview.lua @@ -0,0 +1,90 @@ +return { + { + "sindrets/diffview.nvim", + + keys = { + -- Diffview + { + "dt", + function() + local lib = require("diffview.lib") + + if lib.get_current_view() then + vim.cmd("DiffviewClose") + else + vim.cmd("DiffviewOpen") + end + end, + desc = "Diffview: Toggle", + }, + + -- Current conflict + { + "mo", + function() + require("diffview.config").actions.conflict_choose("ours") + end, + desc = "Merge: Choose Ours", + }, + { + "mt", + function() + require("diffview.config").actions.conflict_choose("theirs") + end, + desc = "Merge: Choose Theirs", + }, + { + "mb", + function() + require("diffview.config").actions.conflict_choose("base") + end, + desc = "Merge: Choose Base", + }, + { + "ma", + function() + require("diffview.config").actions.conflict_choose("all") + end, + desc = "Merge: Keep All", + }, + { + "mx", + function() + require("diffview.config").actions.conflict_choose("none") + end, + desc = "Merge: Delete Conflict", + }, + + -- All conflicts in current file + { + "mO", + function() + require("diffview.config").actions.conflict_choose_all("ours") + end, + desc = "Merge: Choose Ours (All)", + }, + { + "mT", + function() + require("diffview.config").actions.conflict_choose_all("theirs") + end, + desc = "Merge: Choose Theirs (All)", + }, + { + "mA", + function() + require("diffview.config").actions.conflict_choose_all("all") + end, + desc = "Merge: Keep All (All)", + }, + }, + + opts = { + view = { + merge_tool = { + layout = "diff3_mixed", + }, + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/languages/clang.lua b/nvim/.config/nvim/lua/plugins/languages/clang.lua new file mode 100644 index 0000000..8c4e943 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/languages/clang.lua @@ -0,0 +1,67 @@ +return { + -- C/C++ formatter configuration + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + -- Format C source files + c = { "clang_format" }, + + -- Format C header files + h = { "clang_format" }, + + -- Format C++ source files + cpp = { "clang_format" }, + + -- Format C++ header files + hpp = { "clang_format" }, + }, + }, + }, + + -- C/C++ language server configuration + { + "neovim/nvim-lspconfig", + opts = { + servers = { + clangd = { + -- Enable additional clangd features + capabilities = { + offsetEncoding = { "utf-16" }, + }, + + -- clangd command options + cmd = { + "clangd", + "--background-index", + "--clang-tidy", + "--header-insertion=iwyu", + "--completion-style=detailed", + }, + }, + }, + }, + }, + + -- Install C/C++ tools through Mason + { + "mason-org/mason.nvim", + opts = { + ensure_installed = { + "clangd", + "clang-format", + }, + }, + }, + + -- Treesitter support for C/C++ + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "c", + "cpp", + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/languages/java.lua b/nvim/.config/nvim/lua/plugins/languages/java.lua new file mode 100644 index 0000000..0343400 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/languages/java.lua @@ -0,0 +1,119 @@ +return { + -- Java LSP, debugger, and test support + { + "mfussenegger/nvim-jdtls", + ft = "java", + opts = { + settings = { + java = { + -- Download source code for dependencies + eclipse = { + downloadSources = true, + }, + + -- Update Maven/Gradle configuration automatically + configuration = { + updateBuildConfiguration = "interactive", + }, + + -- Java code formatting configuration + format = { + enabled = true, + settings = { + url = vim.fn.stdpath("config") .. "/lang-servers/intellij-java-google-style.xml", + profile = "GoogleStyle", + }, + }, + + -- Additional completion suggestions + completion = { + favoritestaticmembers = { + "org.junit.assert.*", + "org.mockito.mockito.*", + "org.springframework.util.assert.*", + }, + }, + + -- show implementation hints in the editor + implementationscodelens = { + enabled = true, + }, + + -- show reference counters in the editor + referencescodelens = { + enabled = true, + }, + + -- display parameter names as inline hints + inlayhints = { + parameternames = { + enabled = "all", + }, + }, + + -- organize imports automatically on save + saveactions = { + organizeimports = true, + }, + }, + }, + }, + }, + + -- install java syntax parser + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "java", + }, + }, + }, + + -- install required java tools through mason + { + "mason-org/mason.nvim", + opts = { + ensure_installed = { + "google-java-format", + }, + }, + }, + + -- java formatter integration + { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + opts = { + formatters_by_ft = { + java = { "google-java-format" }, + }, + }, + }, + + -- debug adapter protocol support + { + "mfussenegger/nvim-dap", + dependencies = { + "mfussenegger/nvim-dap-ui", + }, + config = function() + local dap = require("dap") + + -- Java debugger provided by JDTLS + require("jdtls").setup_dap({ + hotcodereplace = "auto", + }) + + dap.configurations.java = dap.configurations.java or {} + + table.insert(dap.configurations.java, { + type = "java", + request = "attach", + name = "Attach to Maven exec:java", + hostName = "127.0.0.1", + port = 5005, + }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/languages/json.lua b/nvim/.config/nvim/lua/plugins/languages/json.lua new file mode 100644 index 0000000..4790376 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/languages/json.lua @@ -0,0 +1,34 @@ +return { + -- json formatter integration + { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + opts = { + formatters_by_ft = { + json = { "prettier" }, + jsonc = { "prettier" }, + }, + }, + }, + + -- install required json tools through mason + { + "mason-org/mason.nvim", + opts = { + ensure_installed = { + "prettier", + }, + }, + }, + + -- treesitter json support + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "json", + "jsonc", + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/languages/plantuml.lua b/nvim/.config/nvim/lua/plugins/languages/plantuml.lua new file mode 100644 index 0000000..5b09f16 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/languages/plantuml.lua @@ -0,0 +1,23 @@ +return { + { + "weirongxu/plantuml-previewer.vim", -- main PlantUML plugin + ft = "plantuml", -- lazy-load for PlantUML files + dependencies = { + "tyru/open-browser.vim", -- browser preview dependency + "aklt/plantuml-syntax", -- syntax highlighting for PlantUML + }, + config = function() + -- path to local PlantUML jar (if using local CLI) + vim.g.plantuml_previewer_jar_path = "/usr/share/java/plantuml/plantuml.jar" + + -- output format for generated diagrams + vim.g.plantuml_previewer_output_type = "png" + + -- automatically refresh preview when saving the file + vim.g.plantuml_previewer_refresh_on_save = 1 + + -- default browser for open-browser.vim + vim.g.open_browser_default_browser = "firefox" + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/languages/xml.lua b/nvim/.config/nvim/lua/plugins/languages/xml.lua new file mode 100644 index 0000000..52b2946 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/languages/xml.lua @@ -0,0 +1,28 @@ +return { + { + "mason-org/mason.nvim", + opts = { + ensure_installed = { + "lemminx", + }, + }, + }, + + { + "neovim/nvim-lspconfig", + opts = { + servers = { + lemminx = {}, + }, + }, + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "xml", + }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/utils/scanner.lua b/nvim/.config/nvim/lua/utils/scanner.lua new file mode 100644 index 0000000..83f6a84 --- /dev/null +++ b/nvim/.config/nvim/lua/utils/scanner.lua @@ -0,0 +1,85 @@ +---@class PluginScanner +---@field scan fun(root: string): table + +-- Recursively scans a Lua directory and generates Lazy.nvim import specs. +-- +-- Every directory is converted into a Lazy.nvim import spec, including +-- the root directory itself. +-- +-- Example: +-- +-- ~/.config/nvim/ +-- └── lua/ +-- └── plugins/ +-- ├── ui.lua +-- ├── lsp/ +-- │ ├── lua.lua +-- │ └── python.lua +-- └── languages/ +-- └── rust/ +-- └── dap.lua +-- +-- Generated imports: +-- +-- { import = "plugins" } +-- { import = "plugins.lsp" } +-- { import = "plugins.languages" } +-- { import = "plugins.languages.rust" } +-- +-- Lazy.nvim can then recursively load Lua files from these directories. +-- +-- Files themselves are not returned by the scanner. +-- +-- Note: +-- Importing "plugins" already gives Lazy.nvim access to everything below +-- that directory, so nested imports are technically redundant. They are +-- still returned here because this scanner is explicitly designed to +-- report every discovered directory. + +local M = {} + +---@param root string +---@return table Lazy.nvim import specifications +function M.scan(root) + local result = {} + + local config_path = vim.fn.stdpath("config") + local lua_path = vim.fs.normalize(config_path .. "/lua") + local base = vim.fs.normalize(lua_path .. "/" .. root) + + -- Convert absolute filesystem path to Lua module name. + ---@param path string + ---@return string + local function path_to_module(path) + local module = path:sub(#lua_path + 2) + + return module:gsub("[/\\]", ".") + end + + -- Recursively scan directories. + ---@param dir string + local function scan_dir(dir) + for name, type in vim.fs.dir(dir) do + local path = vim.fs.normalize(dir .. "/" .. name) + + if type == "directory" then + table.insert(result, { + import = path_to_module(path), + }) + + scan_dir(path) + end + end + end + + -- Always include the root directory itself. + table.insert(result, { + import = path_to_module(base), + }) + + scan_dir(base) + + return result +end + +return M diff --git a/nvim/.config/nvim/stylua.toml b/nvim/.config/nvim/stylua.toml new file mode 100644 index 0000000..5d6c50d --- /dev/null +++ b/nvim/.config/nvim/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 120 \ No newline at end of file