refactor: temp

This commit is contained in:
Job
2026-06-24 20:34:11 +02:00
parent e7e37c8dc8
commit 0b90092ff8
5 changed files with 321 additions and 1134 deletions
+91 -133
View File
@@ -1,141 +1,99 @@
local add = vim.pack.add
local now_if_args, later = Config.now_if_args, Config.later
now_if_args(function()
-- Define hook to update tree-sitter parsers after plugin is updated
local ts_update = function()
vim.cmd("TSUpdate")
end
Config.on_packchanged("nvim-treesitter", { "update" }, ts_update, ":TSUpdate")
add({
"https://github.com/nvim-treesitter/nvim-treesitter",
"https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
})
local languages = {
"lua",
"vimdoc",
"markdown",
"go",
"yaml",
"html",
}
local isnt_installed = function(lang)
return #vim.api.nvim_get_runtime_file("parser/" .. lang .. ".*", false) == 0
end
local to_install = vim.tbl_filter(isnt_installed, languages)
if #to_install > 0 then
require("nvim-treesitter").install(to_install)
end
-- Enable tree-sitter after opening a file for a target language
local filetypes = {}
for _, lang in ipairs(languages) do
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
table.insert(filetypes, ft)
end
end
local ts_start = function(ev)
vim.treesitter.start(ev.buf)
end
Config.new_autocmd("FileType", filetypes, ts_start, "Start tree-sitter")
-- Colortheme ==================================================================
Config.now(function()
vim.pack.add({ "https://github.com/rebelot/kanagawa.nvim" })
require("kanagawa").setup({ compile = true })
vim.cmd("colo kanagawa")
end)
-- Language servers ===========================================================
-- Language Server Protocol (LSP) is a set of conventions that power creation of
-- language specific tools. It requires two parts:
-- - Server - program that performs language specific computations.
-- - Client - program that asks server for computations and shows results.
--
-- Here Neovim itself is a client (see `:h vim.lsp`). Language servers need to
-- be installed separately based on your OS, CLI tools, and preferences.
-- See note about 'mason.nvim' at the bottom of the file.
--
-- Neovim's team collects commonly used configurations for most language servers
-- inside 'neovim/nvim-lspconfig' plugin.
--
-- Add it now if file (and not 'mini.starter') is shown after startup.
--
-- Troubleshooting:
-- - Run `:checkhealth vim.lsp` to see potential issues.
now_if_args(function()
add({ "https://github.com/neovim/nvim-lspconfig" })
-- Use `:h vim.lsp.enable()` to automatically enable language server based on
-- the rules provided by 'nvim-lspconfig'.
vim.lsp.enable({
"gopls",
"lua_ls",
"yamlls",
})
-- Use `:h vim.lsp.config()` or 'after/lsp/' directory to configure servers.
-- Uncomment and tweak the following `vim.lsp.enable()` call to enable servers.
-- vim.lsp.config({
-- -- For example, if `lua-language-server` is installed, use `'lua_ls'` entry
-- })
-- Mason ====================================================================
Config.now_if_args(function()
vim.pack.add({ "https://github.com/mason-org/mason.nvim" })
require("mason").setup()
end)
-- Formatting =================================================================
-- Programs dedicated to text formatting (a.k.a. formatters) are very useful.
-- Neovim has built-in tools for text formatting (see `:h gq` and `:h 'formatprg'`).
-- They can be used to configure external programs, but it might become tedious.
--
-- The 'stevearc/conform.nvim' plugin is a good and maintained solution for easier
-- formatting setup.
later(function()
add({ "https://github.com/stevearc/conform.nvim" })
-- See also:
-- - `:h Conform`
-- - `:h conform-options`
-- - `:h conform-formatters`
require("conform").setup({
default_format_opts = {
-- Allow formatting from LSP server if no dedicated formatter is available
lsp_format = "fallback",
},
format_on_save = {
lsp_format = "fallback",
timeout_ms = 500,
},
-- Map of filetype to formatters
-- Make sure that necessary CLI tool is available
-- formatters_by_ft = { lua = { 'stylua' } },
formatters_by_ft = {
go = { "gofumpt", "goimports" },
lua = { "stylua" },
},
})
-- Treesitter ==================================================================
Config.now_if_args(function()
vim.pack.add({ "https://github.com/arborist-ts/arborist.nvim" })
require("arborist").setup()
end)
-- Snippets ===================================================================
-- LSP =========================================================================
Config.now_if_args(function()
vim.pack.add({ "https://github.com/neovim/nvim-lspconfig" })
-- Although 'mini.snippets' provides functionality to manage snippet files, it
-- deliberately doesn't come with those.
--
-- The 'rafamadriz/friendly-snippets' is currently the largest collection of
-- snippet files. They are organized in 'snippets/' directory (mostly) per language.
-- 'mini.snippets' is designed to work with it as seamlessly as possible.
-- See `:h MiniSnippets.gen_loader.from_lang()`.
-- later(function()
-- add({ "https://github.com/rafamadriz/friendly-snippets" })
-- end)
-- Honorable mentions =========================================================
-- 'mason-org/mason.nvim' (a.k.a. "Mason") is a great tool (package manager) for
-- installing external language servers, formatters, and linters. It provides
-- a unified interface for installing, updating, and deleting such programs.
--
-- The caveat is that these programs will be set up to be mostly used inside Neovim.
-- If you need them to work elsewhere, consider using other package managers.
--
-- You can use it like so:
now_if_args(function()
add({ "https://github.com/mason-org/mason.nvim" })
require("mason").setup()
vim.lsp.enable({
"ansiblels",
"gopls",
"intelephense",
"lua_ls",
"tailwindcss",
"vtsls",
})
end)
-- Conform =====================================================================
Config.now_if_args(function()
vim.pack.add({ "https://github.com/stevearc/conform.nvim" })
require("conform").setup({
default_format_opts = { lsp_format = "fallback" },
format_on_save = {
lsp_format = "fallback",
timeout_ms = 500,
},
formatters_by_ft = {
go = { "gofumpt", "goimports" },
php = { "php_cs_fixer" },
},
})
end)
-- DAP =========================================================================
function Config.setup_dap()
if package.loaded["dap"] then
return
end
vim.pack.add({ "https://github.com/mfussenegger/nvim-dap" })
local dap = require("dap")
dap.adapters.php = {
type = "executable",
command = "node",
args = { vim.fn.stdpath("data") .. "/mason/packages/php-debug-adapter/extension/out/phpDebug.js" },
}
dap.adapters.go = {
type = "server",
host = "127.0.0.1",
port = "${port}",
}
end
-- Kulala ======================================================================
function Config.setup_kulala()
if package.loaded["kulala"] then
return
end
vim.pack.add({ "https://github.com/mistweaverco/kulala.nvim" })
require("kulala").setup({ default_env = "dev" })
end
-- CodeCompanion ===============================================================
function Config.setup_codecompanion()
if package.loaded["codecompanion"] then
return
end
vim.pack.add({
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/olimorris/codecompanion.nvim"
})
require("codecompanion").setup({
completion = {
provider = "native"
}
})
end