From 8a9cc4328dc2e564a5ab95c814a2e1d16d73b907 Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Mon, 12 Feb 2024 00:09:58 -0600 Subject: [PATCH] update --- .stylua.toml | 6 ++ lazy-lock.json | 86 +++++++++++++------------ lua/rayandrew/autocmds.lua | 14 +++- lua/rayandrew/plugins/editor.lua | 69 ++++++++++++++++++-- lua/rayandrew/plugins/file.lua | 23 ++++++- lua/rayandrew/plugins/general.lua | 30 +++++++-- lua/rayandrew/plugins/lsp.lua | 97 ++-------------------------- lua/rayandrew/theme.lua | 7 ++ lua/rayandrew/tools.lua | 103 ++++++++++++++++++++++++++++++ 9 files changed, 289 insertions(+), 146 deletions(-) create mode 100644 .stylua.toml create mode 100644 lua/rayandrew/tools.lua diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..6090f42 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" diff --git a/lazy-lock.json b/lazy-lock.json index 5944180..f69a2af 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,63 +1,65 @@ { - "LuaSnip": { "branch": "master", "commit": "82108e7e31cc6fc223cc5df5cae6d89f70bb199f" }, + "LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" }, "bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" }, "cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" }, - "cloak.nvim": { "branch": "main", "commit": "951b163e55ce7639eb320c450bde9283c4fe968b" }, + "chezmoi.nvim": { "branch": "refactor", "commit": "4fbd33d7510e4a9697fa8b60181b9066b19399a1" }, + "chezmoi.vim": { "branch": "main", "commit": "a35b426db9d83f8fcf43981f299ad3145d001af2" }, + "cloak.nvim": { "branch": "main", "commit": "9abe4e986e924fc54a972c1b0ff52b65a0622624" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, - "conform.nvim": { "branch": "master", "commit": "75e7c5c7eb5fbd53f8b12dc420b31ec70770b231" }, - "copilot.vim": { "branch": "release", "commit": "1a55183ef9347d6f420406a3746474b6b9fb9ef5" }, - "everforest": { "branch": "main", "commit": "06a600c4fa49e7a4c44848d14c353ecbaab8eb9f" }, - "focus.nvim": { "branch": "master", "commit": "c83be53de558f6f0824c8cefcad61719c87ce157" }, - "gitsigns.nvim": { "branch": "main", "commit": "3e6e91b09f0468c32d3b96dcacf4b947f037ce25" }, + "conform.nvim": { "branch": "master", "commit": "c0e0e80f0c233cb3a249f719a44324c660163a3f" }, + "copilot.vim": { "branch": "release", "commit": "315c6d2b16e018cb8020f20aaa7081ebc4070828" }, + "everforest": { "branch": "main", "commit": "63ea67d948ddbc9915055a815ca0686930dc73d5" }, + "focus.nvim": { "branch": "master", "commit": "4135f976afe5d6e1fe66dff121db9d06643f439f" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, "glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" }, "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, - "image.nvim": { "branch": "master", "commit": "245422e5c4774f0640d41c0eadec77396f2be4a9" }, - "indent-blankline.nvim": { "branch": "master", "commit": "3c8a185da4b8ab7aef487219f5e001b11d4b6aaf" }, - "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, - "lsp-zero.nvim": { "branch": "v3.x", "commit": "433db11e818d07a5151e2c750ca8f09cc2aa3146" }, - "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "8b70e7f1e0a4119c1234c3bde4a01c241cabcc74" }, - "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, + "image.nvim": { "branch": "master", "commit": "77df64af37ff68a1f593aa4f79b42b1388479239" }, + "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, + "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "abac76482ec3012a2b359ba956a74e2ffd33d46f" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0954d7730e749d606ddf8d7ae8846848be435d53" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "bf0f4f8062d3acbe0afcc61db01a4d19d96310e4" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "meh": { "branch": "master", "commit": "e2962284bbd53db5cbe2db39efaa3ea74ade0fb1" }, - "mini.bufremove": { "branch": "main", "commit": "020243bfed8c8b941f2c20626faf3ea39c0c0e1b" }, - "mini.comment": { "branch": "main", "commit": "67f00d3ebbeae15e84584d971d0c32aad4f4f3a4" }, + "mini.bufremove": { "branch": "main", "commit": "931a3bb514147d9e812767275c4beba6b779b1d3" }, + "mini.comment": { "branch": "main", "commit": "68a1e9de2ea47268205503ab1dcd48ff79648251" }, "nabla.nvim": { "branch": "master", "commit": "27a6ea9ed7452bb9e0b19eb0942b5bcf7d051b2f" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "e578fe7a5832421b0d2c5b3c0a7a1e40e0f6a47a" }, "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, "nvim-bqf": { "branch": "main", "commit": "bdc2a4e5bb670b3c0e33ada9c0eec636d93a0748" }, - "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, - "nvim-lint": { "branch": "master", "commit": "8df53b5dde8ea80f0a039775777eae6648a10229" }, - "nvim-lspconfig": { "branch": "master", "commit": "796394fd19fb878e8dbc4fd1e9c9c186ed07a5f4" }, - "nvim-spectre": { "branch": "master", "commit": "d8906855f1949ac97b1e77aaf8d3fe12ed158ddc" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-lint": { "branch": "master", "commit": "966ab3dc37eee3e413692264b44a3011b05a6060" }, + "nvim-lspconfig": { "branch": "master", "commit": "e655c96cf00f7b783871b3787187ed3fa25ff64e" }, + "nvim-spectre": { "branch": "master", "commit": "6a0785ef64c839d935a2f92e20988e962fb6537e" }, "nvim-surround": { "branch": "main", "commit": "703ec63aa798e5e07d309b35e42def34bebe0174" }, - "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, - "nvim-treesitter-context": { "branch": "master", "commit": "400a99ad43ac78af1148061da3491cba2637ad29" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "85b9d0cbd4ff901abcda862b50dbb34e0901848b" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "1277b4a1f451b0f18c0790e1a7f12e1e5fdebfee" }, - "nvim-web-devicons": { "branch": "master", "commit": "db0c864375c198cacc171ff373e76bfce2a85045" }, - "oil.nvim": { "branch": "master", "commit": "c4cc8240f1c71defcb67c45da96e44b968d29e5f" }, + "nvim-treesitter": { "branch": "master", "commit": "10e8dffb7961fae98cf83efa0e170c22ae2cd33a" }, + "nvim-treesitter-context": { "branch": "master", "commit": "f2ef98cd18fca352448756d3feb6e58d82583274" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "dd0b2036c3a27cb6e6486f8bd24188c6ca43af0b" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, + "nvim-web-devicons": { "branch": "master", "commit": "7f30f2da3c3641841ceb0e2c150281f624445e8f" }, + "oil.nvim": { "branch": "master", "commit": "bf753c3e3f8736939ad5597f92329dfe7b1df4f5" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, - "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "rasmus": { "branch": "main", "commit": "f824de95d446686e479781c0c2b778c177da528f" }, "readline.nvim": { "branch": "main", "commit": "5cb27349bc01cdcdb3d3494e5337d8b3834aef1a" }, - "refactoring.nvim": { "branch": "master", "commit": "c067e44b8171494fc1b5206ab4c267cd74c043b1" }, - "rose-pine": { "branch": "main", "commit": "67b03139fe43f1fcd03cb34620ec3d41eb407793" }, - "smart-splits.nvim": { "branch": "master", "commit": "2009a38ac44ec7afa1a001e0dfa8358441510a64" }, + "refactoring.nvim": { "branch": "master", "commit": "fb4990a0546c59136930ea624b8640d07957f281" }, + "rose-pine": { "branch": "main", "commit": "f01ce3a71748a92997d266cfe2c985decd18c601" }, + "smart-splits.nvim": { "branch": "master", "commit": "36bfe63246386fc5ae2679aa9b17a7746b7403d5" }, "symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, - "telescope.nvim": { "branch": "master", "commit": "b3ff5f33201f474d58f5be96244869f189bbc091" }, - "todo-comments.nvim": { "branch": "main", "commit": "4a6737a8d70fe1ac55c64dfa47fcb189ca431872" }, - "tree-sitter-just": { "branch": "main", "commit": "195d414109b8177b49aa7525f8bd3b170275c9a0" }, + "telescope.nvim": { "branch": "master", "commit": "0f865f17af4f9bc1587a0132414cdfd32d91852e" }, + "todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, + "tree-sitter-just": { "branch": "main", "commit": "4f5d53b52a65771f9695df3f1a294d5c80b916fb" }, "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, - "undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" }, + "undotree": { "branch": "master", "commit": "9dbbf3b7d19dda0d22ceca461818e4739ad8154d" }, "venn.nvim": { "branch": "main", "commit": "e4d68341a73dd56c64955058821a58295fb337b1" }, - "vim-dispatch": { "branch": "master", "commit": "6cc2691576f97d43f8751664d1a1a908b99927e5" }, - "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, - "vim-illuminate": { "branch": "master", "commit": "3bd2ab64b5d63b29e05691e624927e5ebbf0fb86" }, - "vim-startuptime": { "branch": "master", "commit": "454b3de856b7bd298700de33d79774ca9b9e3875" }, + "vim-dispatch": { "branch": "master", "commit": "b84d00f11567abfcfec82a6838c7d41dfa49a447" }, + "vim-fugitive": { "branch": "master", "commit": "9f92ff14d9d1169e08f197a2250fcaea88e9c767" }, + "vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" }, + "vim-startuptime": { "branch": "master", "commit": "ab5acd23f39347bab04904df2177e114bffb97a8" }, "vim-tmux-navigator": { "branch": "master", "commit": "38b1d0402c4600543281dc85b3f51884205674b6" }, - "vimtex": { "branch": "master", "commit": "f9b19d09ee6f0ba70dad0b5c2e710dd700681000" }, + "vimtex": { "branch": "master", "commit": "9df79e15bf035d1cfb32c11fffed38dd7b6a0501" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, - "zen-mode.nvim": { "branch": "main", "commit": "50e2e2a36cc97847d9ab3b1a3555ba2ef6839b50" } + "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } } \ No newline at end of file diff --git a/lua/rayandrew/autocmds.lua b/lua/rayandrew/autocmds.lua index b4aeefa..9389ef2 100644 --- a/lua/rayandrew/autocmds.lua +++ b/lua/rayandrew/autocmds.lua @@ -104,8 +104,20 @@ autocmd({ "BufWritePre" }, { -- end, -- }) -vim.api.nvim_create_autocmd({ "VimLeave" }, { +autocmd({ "VimLeave" }, { callback = function() vim.fn.jobstart('notify-send "hello"', { detach = true }) end, }) + +-- translate vimscript below into nvim lua api +-- autocmd BufWritePost ~/.local/share/chezmoi/* ! chezmoi apply --source-path "%" +-- autocmd({ "BufWritePost" }, { +-- group = augroup("chezmoi_apply"), +-- pattern = "~/.local/share/chezmoi/*", +-- callback = function(event) +-- print("chezmoi apply --source-path " .. event.match) +-- -- vim.fn.jobstart("chezmoi apply --source-path " .. event.match, { detach = true }) +-- end, +-- -- command = [[! chezmoi apply --source-path "%"]], +-- }) diff --git a/lua/rayandrew/plugins/editor.lua b/lua/rayandrew/plugins/editor.lua index e8d3740..4088f4d 100644 --- a/lua/rayandrew/plugins/editor.lua +++ b/lua/rayandrew/plugins/editor.lua @@ -6,12 +6,12 @@ return { 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)" }, - { "xT", "TodoTrouble keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme (Trouble)" }, - { "st", "TodoTelescope", desc = "Todo" }, - { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, + { "]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)" }, + { "xT", "TodoTrouble keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme (Trouble)" }, + { "st", "TodoTelescope", desc = "Todo" }, + { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, }, }, @@ -157,4 +157,61 @@ return { require("cloak").setup(opts) end, }, + + -- chezmoi + { + "alker0/chezmoi.vim", + lazy = false, + init = function() + -- This option is required. + vim.g["chezmoi#use_tmp_buffer"] = true + -- add other options here if needed. + end, + }, + + { + "xvzc/chezmoi.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + branch = "refactor", + opts = { + edit = { + watch = true, -- Set true to automatically apply on save. + force = true, -- Set true to force apply. Works only when watch = true. + }, + notification = { + on_open = false, -- vim.notify when start editing chezmoi-managed file. + on_save = true, -- vim.notify on apply. + on_watch = true, + }, + }, + config = function(_, opts) + -- local chezmoi_dir = os.getenv("HOME") .. "/.config/dotfiles" + local dotfiles_dir = os.getenv("HOME") .. "/Code/dotfiles" + local chezmoi_dir = dotfiles_dir .. "/chezmoi" + local Util = require("rayandrew.util") + local telescope_ok, telescope = pcall(require, "telescope") + if telescope_ok then + telescope.load_extension("chezmoi") + -- check if current directory is a chezmoi directory + local cwd = vim.fn.getcwd() + if cwd == chezmoi_dir then + Util.map("n", "ff", telescope.extensions.chezmoi.find_files, { noremap = true, silent = true }) + Util.map("n", "fc", Util.telescope("files", { cwd = false }), { noremap = true, silent = true }) + else + Util.map("n", "fc", telescope.extensions.chezmoi.find_files, { noremap = true, silent = true }) + Util.map("n", "ff", Util.telescope("files", { cwd = false }), { noremap = true, silent = true }) + end + end + + vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + -- pattern = { os.getenv("HOME") .. "/.local/share/chezmoi/*" }, + pattern = { chezmoi_dir .. "/*" }, + -- pattern = { require("chezmoi").source_path }, + callback = function() + -- invoke with vim.schedule() for better startup time + vim.schedule(require("chezmoi.commands.__edit").watch) + end, + }) + end, + }, } diff --git a/lua/rayandrew/plugins/file.lua b/lua/rayandrew/plugins/file.lua index ab93b4c..a8af0e6 100644 --- a/lua/rayandrew/plugins/file.lua +++ b/lua/rayandrew/plugins/file.lua @@ -13,7 +13,7 @@ return { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended "MunifTanjim/nui.nvim", - "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information }, opts = { sources = { "filesystem", "buffers", "git_status", "document_symbols" }, @@ -50,6 +50,25 @@ return { vim.fn.setreg("+", filepath) vim.notify("Copied: " .. filepath) end, + ["O"] = { + command = function(state) + local node = state.tree:get_node() + local filepath = node.path + local osType = os.getenv("OS") + + local command + + if osType == "Windows_NT" then + command = "start " .. filepath + elseif osType == "Darwin" then + command = "open " .. filepath + else + command = "xdg-open " .. filepath + end + os.execute(command) + end, + desc = "open_with_system_defaults", + }, }, }, default_component_configs = { @@ -96,7 +115,7 @@ return { local events = require("neo-tree.events") opts.event_handlers = opts.event_handlers or {} vim.list_extend(opts.event_handlers, { - { event = events.FILE_MOVED, handler = on_move }, + { event = events.FILE_MOVED, handler = on_move }, { event = events.FILE_RENAMED, handler = on_move }, }) require("neo-tree").setup(opts) diff --git a/lua/rayandrew/plugins/general.lua b/lua/rayandrew/plugins/general.lua index 027cc88..0cf5527 100644 --- a/lua/rayandrew/plugins/general.lua +++ b/lua/rayandrew/plugins/general.lua @@ -1,5 +1,5 @@ return { - { "folke/lazy.nvim", version = "*" }, + { "folke/lazy.nvim", version = "*" }, { "nvim-lua/plenary.nvim", lazy = true }, { @@ -31,7 +31,29 @@ return { lazy = true, }, - { "neanias/everforest-nvim", lazy = true, name = "everforest", opts = { - background = "hard", - } }, + { + "neanias/everforest-nvim", + lazy = true, + name = "everforest", + opts = { + background = "hard", + } + }, + + -- { + -- "f-person/auto-dark-mode.nvim", + -- config = { + -- update_interval = 1000, + -- set_dark_mode = function() + -- vim.o.background = "dark" + -- -- vim.api.nvim_set_option("background", "dark") + -- -- vim.cmd("colorscheme gruvbox") + -- end, + -- set_light_mode = function() + -- vim.o.background = "light" + -- -- vim.api.nvim_set_option("background", "light") + -- -- vim.cmd("colorscheme gruvbox") + -- end, + -- }, + -- }, } diff --git a/lua/rayandrew/plugins/lsp.lua b/lua/rayandrew/plugins/lsp.lua index 4b9dfb2..bcc75fe 100644 --- a/lua/rayandrew/plugins/lsp.lua +++ b/lua/rayandrew/plugins/lsp.lua @@ -2,94 +2,9 @@ -- LSP CONFIGURATION -- ------------------------------ +local tools = require("rayandrew.tools") local slow_format_filetypes = {} --- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 -local linters = { - lua = { "selene" }, - css = { "stylelint" }, - sh = { "shellcheck" }, - markdown = { "markdownlint", "vale" }, - yaml = { "yamllint" }, - python = { "pylint" }, - gitcommit = {}, - json = {}, - javascript = {}, - typescript = {}, - toml = {}, - applescript = {}, - bib = {}, -} - --- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 --- PENDING https://github.com/mfussenegger/nvim-lint/issues/355 -for ft, _ in pairs(linters) do - table.insert(linters[ft], "codespell") - table.insert(linters[ft], "editorconfig-checker") -end - --- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 -local formatters = { - lua = { "stylua" }, - python = { "isort", "black" }, - javascript = { "biome" }, - typescript = { "biome" }, - json = { "biome" }, - jsonc = { "biome" }, - nix = { "nixpkgs_fmt" }, - yaml = { "prettier" }, - html = { "prettier" }, - markdown = { - "markdown-toc", - "markdownlint", - -- "injected", - }, - css = { "stylelint", "prettier" }, - sh = { "shellcheck", "shfmt" }, - bib = { "trim_whitespace", "bibtex-tidy" }, - ["_"] = { "trim_whitespace", "trim_newlines", "squeeze_blanks" }, - ["*"] = { "codespell" }, -} - -local debuggers = {} - -local dontInstall = { - -- installed externally due to its plugins: https://github.com/williamboman/mason.nvim/issues/695 - "stylelint", - -- not real formatters, but pseudo-formatters from conform.nvim - "trim_whitespace", - "trim_newlines", - "squeeze_blanks", - "injected", - "nixpkgs_fmt", -} - ----given the linter- and formatter-list of nvim-lint and conform.nvim, extract a ----list of all tools that need to be auto-installed ----@param myLinters object[] ----@param myFormatters object[] ----@param myDebuggers string[] ----@param ignoreTools string[] ----@return string[] tools ----@nodiscard -local function toolsToAutoinstall(myLinters, myFormatters, myDebuggers, ignoreTools) - -- get all linters, formatters, & debuggers and merge them into one list - local linterList = vim.tbl_flatten(vim.tbl_values(myLinters)) - local formatterList = vim.tbl_flatten(vim.tbl_values(myFormatters)) - local tools = vim.list_extend(linterList, formatterList) - vim.list_extend(tools, myDebuggers) - - -- only unique tools - table.sort(tools) - tools = vim.fn.uniq(tools) - - -- remove exceptions not to install - tools = vim.tbl_filter(function(tool) - return not vim.tbl_contains(ignoreTools, tool) - end, tools) - return tools -end - return { { { @@ -191,7 +106,7 @@ return { }, }, opts = { - formatters_by_ft = formatters, + formatters_by_ft = tools.formatters, format_on_save = function(bufnr) if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return @@ -287,7 +202,7 @@ return { event = "VeryLazy", config = function() local lint = require("lint") - lint.linters_by_ft = linters + lint.linters_by_ft = tools.linters lint.linters.shellcheck.args = { "--shell=bash", "--format=json", "-" } lint.linters.markdownlint.args = { @@ -296,7 +211,7 @@ return { } lint.linters["editorconfig-checker"].args = { "-no-color", - "-disable-max-line-length", -- only rule of thumb + "-disable-max-line-length", -- only rule of thumb "-disable-trim-trailing-whitespace", -- will be formatted anyway } end, @@ -310,10 +225,10 @@ return { }, dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim" }, config = function() - local tools = toolsToAutoinstall(linters, formatters, debuggers, dontInstall) + local tools_to_install = tools.getToolsToInstall() require("mason-tool-installer").setup({ - ensure_installed = tools, + ensure_installed = tools_to_install, run_on_start = false, -- triggered manually, since not working with lazy-loading }) diff --git a/lua/rayandrew/theme.lua b/lua/rayandrew/theme.lua index 54447fb..3779fb3 100644 --- a/lua/rayandrew/theme.lua +++ b/lua/rayandrew/theme.lua @@ -4,6 +4,7 @@ local M = {} -- M.colorscheme = "meh" -- M.colorscheme = "rasmus" M.colorscheme = "everforest" +M.background = "dark" -- M.colorscheme = "" function M.setup() @@ -18,6 +19,12 @@ function M.setup() else vim.cmd.colorscheme(M.colorscheme) end + + if M.background == "" then + return + end + + vim.o.background = M.background end, { msg = "Could not load your colorscheme", on_error = function(msg) diff --git a/lua/rayandrew/tools.lua b/lua/rayandrew/tools.lua new file mode 100644 index 0000000..cc4437f --- /dev/null +++ b/lua/rayandrew/tools.lua @@ -0,0 +1,103 @@ +local M = {} + +local lsps = { + lua = { "lua-language-server" }, + python = { "pyright" }, +} + + +-- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 +M.linters = { + lua = { "selene" }, + css = { "stylelint" }, + sh = { "shellcheck" }, + markdown = { "markdownlint", "vale" }, + yaml = { "yamllint" }, + python = { "pylint" }, + gitcommit = {}, + json = {}, + javascript = {}, + typescript = {}, + toml = {}, + applescript = {}, + bib = {}, +} + +-- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 +-- PENDING https://github.com/mfussenegger/nvim-lint/issues/355 +for ft, _ in pairs(M.linters) do + table.insert(M.linters[ft], "codespell") + table.insert(M.linters[ft], "editorconfig-checker") +end + +-- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 +M.formatters = { + lua = { "stylua" }, + python = { "isort", "black" }, + javascript = { "biome" }, + typescript = { "biome" }, + json = { "biome" }, + jsonc = { "biome" }, + nix = { "alejandra" }, + yaml = { "prettier" }, + html = { "prettier" }, + markdown = { + "markdown-toc", + "markdownlint", + -- "injected", + }, + css = { "stylelint", "prettier" }, + sh = { "shellcheck", "shfmt" }, + bib = { "trim_whitespace", "bibtex-tidy" }, + ["_"] = { "trim_whitespace", "trim_newlines", "squeeze_blanks" }, + ["*"] = { "codespell" }, +} + +M.debuggers = {} + +M.dontInstall = { + -- installed externally due to its plugins: https://github.com/williamboman/mason.nvim/issues/695 + "stylelint", + -- not real formatters, but pseudo-formatters from conform.nvim + "trim_whitespace", + "trim_newlines", + "squeeze_blanks", + "injected", + "alejandra", + "nixpkgs_fmt", +} + +---given the linter- and formatter-list of nvim-lint and conform.nvim, extract a +---list of all tools that need to be auto-installed +---@param myLinters object[] +---@param myFormatters object[] +---@param myDebuggers string[] +---@param ignoreTools string[] +---@return string[] tools +---@nodiscard +function toolsToAutoinstall(myLinters, myFormatters, myDebuggers, ignoreTools) + -- get all linters, formatters, & debuggers and merge them into one list + local lspList = vim.tbl_flatten(vim.tbl_values(lsps)) + local linterList = vim.tbl_flatten(vim.tbl_values(myLinters)) + local formatterList = vim.tbl_flatten(vim.tbl_values(myFormatters)) + local tools = vim.list_extend(linterList, formatterList) + vim.list_extend(tools, lspList) + vim.list_extend(tools, myDebuggers) + + -- only unique tools + table.sort(tools) + tools = vim.fn.uniq(tools) + + -- remove exceptions not to install + tools = vim.tbl_filter(function(tool) + return not vim.tbl_contains(ignoreTools, tool) + end, tools) + return tools +end + +function M.getToolsToInstall() + local tools = toolsToAutoinstall(M.linters, M.formatters, M.debuggers, M.dontInstall) + return tools +end + +return M