update:code shift
This commit is contained in:
@@ -30,7 +30,7 @@ local function apply_theme_overrides()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "catppuccin", "nvim-web-devicons" })
|
pack.add({ "catppuccin" })
|
||||||
|
|
||||||
local theme_group = vim.api.nvim_create_augroup("UserThemeTweaks", { clear = true })
|
local theme_group = vim.api.nvim_create_augroup("UserThemeTweaks", { clear = true })
|
||||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||||
|
|||||||
@@ -1,25 +1,8 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local pack = require("utils.pack")
|
local pack = require("utils.pack")
|
||||||
|
local mason_utils = require("utils.mason")
|
||||||
local tools = {
|
local lsp_tools = require("plugins.lsp_tools")
|
||||||
{ kind = "lsp", lsp = "lua_ls", mason = "lua-language-server" },
|
|
||||||
{ kind = "lsp", lsp = "bashls", mason = "bash-language-server" },
|
|
||||||
{ kind = "lsp", lsp = "astro", mason = "astro-language-server" },
|
|
||||||
{ kind = "lsp", lsp = "tailwindcss", mason = "tailwindcss-language-server" },
|
|
||||||
{ kind = "lsp", lsp = "ts_ls", mason = "typescript-language-server" },
|
|
||||||
{ kind = "lsp", lsp = "html", mason = "html-lsp" },
|
|
||||||
{ kind = "lsp", lsp = "pyright", mason = "pyright" },
|
|
||||||
{ kind = "lsp", lsp = "templ", mason = "templ" },
|
|
||||||
{ kind = "lsp", lsp = "gopls", mason = "gopls" },
|
|
||||||
{ kind = "lsp", lsp = "emmet_ls", mason = "emmet-language-server" },
|
|
||||||
{ kind = "lsp", lsp = "rust_analyzer", mason = "rust-analyzer" },
|
|
||||||
{ kind = "formatter", mason = "stylua", ft = { "lua" } },
|
|
||||||
{ kind = "formatter", mason = "shfmt", ft = { "sh", "bash" } },
|
|
||||||
{ kind = "formatter", mason = "isort", ft = { "python" } },
|
|
||||||
{ kind = "formatter", mason = "black", ft = { "python" } },
|
|
||||||
{ kind = "formatter", mason = "prettierd", ft = { "javascript", "typescript", "astro", "html", "css", "json", "jsonc" } },
|
|
||||||
}
|
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "mason", "nvim-lspconfig", "conform" })
|
pack.add({ "mason", "nvim-lspconfig", "conform" })
|
||||||
@@ -42,7 +25,16 @@ function M.setup()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
filetypes = { "htmldjango", "templ", "html", "css", "javascript", "typescript", "jsx", "tsx" },
|
filetypes = {
|
||||||
|
"htmldjango",
|
||||||
|
"templ",
|
||||||
|
"html",
|
||||||
|
"css",
|
||||||
|
"javascript",
|
||||||
|
"typescript",
|
||||||
|
"javascriptreact",
|
||||||
|
"typescriptreact",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
vim.lsp.config("html", { filetypes = { "html", "htmldjango", "templ" } })
|
vim.lsp.config("html", { filetypes = { "html", "htmldjango", "templ" } })
|
||||||
vim.lsp.config("lua_ls", {
|
vim.lsp.config("lua_ls", {
|
||||||
@@ -56,58 +48,17 @@ function M.setup()
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
local lsp_names = {}
|
vim.lsp.enable(lsp_tools.lsp_names())
|
||||||
for _, t in ipairs(tools) do
|
|
||||||
if t.kind == "lsp" then
|
|
||||||
table.insert(lsp_names, t.lsp)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
vim.lsp.enable(lsp_names)
|
|
||||||
|
|
||||||
require("conform").setup({
|
require("conform").setup({
|
||||||
formatters_by_ft = {
|
formatters_by_ft = lsp_tools.formatters_by_ft(),
|
||||||
lua = { "stylua" },
|
|
||||||
sh = { "shfmt" },
|
|
||||||
bash = { "shfmt" },
|
|
||||||
python = { "isort", "black" },
|
|
||||||
javascript = { "prettierd" },
|
|
||||||
typescript = { "prettierd" },
|
|
||||||
astro = { "prettierd" },
|
|
||||||
html = { "prettierd" },
|
|
||||||
css = { "prettierd" },
|
|
||||||
json = { "prettierd" },
|
|
||||||
jsonc = { "prettierd" },
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>F", function()
|
vim.keymap.set("n", "<leader>F", function()
|
||||||
require("conform").format({ async = true, lsp_fallback = true })
|
require("conform").format({ async = true, lsp_fallback = true })
|
||||||
end, { desc = "Format buffer" })
|
end, { desc = "Format buffer" })
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("MasonInstallDefaults", function()
|
mason_utils.setup_install_defaults_command(lsp_tools.tools)
|
||||||
local registry = require("mason-registry")
|
|
||||||
registry.refresh(function()
|
|
||||||
local seen, to_install = {}, {}
|
|
||||||
for _, t in ipairs(tools) do
|
|
||||||
if t.mason and not seen[t.mason] then
|
|
||||||
seen[t.mason] = true
|
|
||||||
local ok, pkg = pcall(registry.get_package, t.mason)
|
|
||||||
if ok and not pkg:is_installed() then
|
|
||||||
table.insert(to_install, pkg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if #to_install == 0 then
|
|
||||||
vim.notify("MasonInstallDefaults: all tools already installed", vim.log.levels.INFO)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
for _, pkg in ipairs(to_install) do
|
|
||||||
pkg:install()
|
|
||||||
end
|
|
||||||
vim.notify(("MasonInstallDefaults: installing %d tool(s)"):format(#to_install), vim.log.levels.INFO)
|
|
||||||
end)
|
|
||||||
end, { desc = "Install missing Mason tools from `tools` table" })
|
|
||||||
|
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
vim.diagnostic.config({ virtual_text = false })
|
||||||
|
|
||||||
|
|||||||
46
nvim/lua/plugins/lsp_tools.lua
Normal file
46
nvim/lua/plugins/lsp_tools.lua
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.tools = {
|
||||||
|
{ kind = "lsp", lsp = "lua_ls", mason = "lua-language-server" },
|
||||||
|
{ kind = "lsp", lsp = "bashls", mason = "bash-language-server" },
|
||||||
|
{ kind = "lsp", lsp = "astro", mason = "astro-language-server" },
|
||||||
|
{ kind = "lsp", lsp = "tailwindcss", mason = "tailwindcss-language-server" },
|
||||||
|
{ kind = "lsp", lsp = "ts_ls", mason = "typescript-language-server" },
|
||||||
|
{ kind = "lsp", lsp = "html", mason = "html-lsp" },
|
||||||
|
{ kind = "lsp", lsp = "pyright", mason = "pyright" },
|
||||||
|
{ kind = "lsp", lsp = "templ", mason = "templ" },
|
||||||
|
{ kind = "lsp", lsp = "gopls", mason = "gopls" },
|
||||||
|
{ kind = "lsp", lsp = "emmet_ls", mason = "emmet-language-server" },
|
||||||
|
{ kind = "lsp", lsp = "rust_analyzer", mason = "rust-analyzer" },
|
||||||
|
{ kind = "formatter", mason = "stylua", ft = { "lua" } },
|
||||||
|
{ kind = "formatter", mason = "shfmt", ft = { "sh", "bash" } },
|
||||||
|
{ kind = "formatter", mason = "isort", ft = { "python" } },
|
||||||
|
{ kind = "formatter", mason = "black", ft = { "python" } },
|
||||||
|
{ kind = "formatter", mason = "prettierd", ft = { "javascript", "typescript", "astro", "html", "css", "json", "jsonc" } },
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.lsp_names()
|
||||||
|
local names = {}
|
||||||
|
for _, tool in ipairs(M.tools) do
|
||||||
|
if tool.kind == "lsp" then
|
||||||
|
table.insert(names, tool.lsp)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return names
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.formatters_by_ft()
|
||||||
|
local by_ft = {}
|
||||||
|
for _, tool in ipairs(M.tools) do
|
||||||
|
if tool.kind == "formatter" and tool.ft then
|
||||||
|
local formatter = tool.conform or tool.mason
|
||||||
|
for _, ft in ipairs(tool.ft) do
|
||||||
|
by_ft[ft] = by_ft[ft] or {}
|
||||||
|
table.insert(by_ft[ft], formatter)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return by_ft
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -9,12 +9,6 @@ function M.setup()
|
|||||||
options = {
|
options = {
|
||||||
custom_commentstring = function()
|
custom_commentstring = function()
|
||||||
local ft = vim.bo.filetype
|
local ft = vim.bo.filetype
|
||||||
if ft == "typescriptreact" then
|
|
||||||
return "{/* %s */}"
|
|
||||||
end
|
|
||||||
if ft == "htmldjango" then
|
|
||||||
return "{# %s #}"
|
|
||||||
end
|
|
||||||
if ft == "templ" then
|
if ft == "templ" then
|
||||||
return "// %s"
|
return "// %s"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ local M = {}
|
|||||||
local pack = require("utils.pack")
|
local pack = require("utils.pack")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "indent-blankline.nvim", "lualine.nvim", "bufferline.nvim" })
|
pack.add({ "nvim-web-devicons", "indent-blankline.nvim", "lualine.nvim", "bufferline.nvim" })
|
||||||
|
|
||||||
require("ibl").setup({
|
require("ibl").setup({
|
||||||
indent = { char = "▏" },
|
indent = { char = "▏" },
|
||||||
|
|||||||
31
nvim/lua/utils/mason.lua
Normal file
31
nvim/lua/utils/mason.lua
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.setup_install_defaults_command(tools)
|
||||||
|
pcall(vim.api.nvim_del_user_command, "MasonInstallDefaults")
|
||||||
|
vim.api.nvim_create_user_command("MasonInstallDefaults", function()
|
||||||
|
local registry = require("mason-registry")
|
||||||
|
registry.refresh(function()
|
||||||
|
local seen, to_install = {}, {}
|
||||||
|
for _, tool in ipairs(tools) do
|
||||||
|
if tool.mason and not seen[tool.mason] then
|
||||||
|
seen[tool.mason] = true
|
||||||
|
local ok, pkg = pcall(registry.get_package, tool.mason)
|
||||||
|
if ok and not pkg:is_installed() then
|
||||||
|
table.insert(to_install, pkg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #to_install == 0 then
|
||||||
|
vim.notify("MasonInstallDefaults: all tools already installed", vim.log.levels.INFO)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for _, pkg in ipairs(to_install) do
|
||||||
|
pkg:install()
|
||||||
|
end
|
||||||
|
vim.notify(("MasonInstallDefaults: installing %d tool(s)"):format(#to_install), vim.log.levels.INFO)
|
||||||
|
end)
|
||||||
|
end, { desc = "Install missing Mason tools from tool registry" })
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -68,6 +68,10 @@
|
|||||||
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
|
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
|
||||||
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
|
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
|
||||||
},
|
},
|
||||||
|
"nvim-ts-autotag": {
|
||||||
|
"rev": "8e1c0a389f20bf7f5b0dd0e00306c1247bda2595",
|
||||||
|
"src": "https://github.com/windwp/nvim-ts-autotag"
|
||||||
|
},
|
||||||
"nvim-web-devicons": {
|
"nvim-web-devicons": {
|
||||||
"rev": "c72328a5494b4502947a022fe69c0c47e53b6aa6",
|
"rev": "c72328a5494b4502947a022fe69c0c47e53b6aa6",
|
||||||
"src": "https://github.com/nvim-tree/nvim-web-devicons"
|
"src": "https://github.com/nvim-tree/nvim-web-devicons"
|
||||||
|
|||||||
Reference in New Issue
Block a user