Fixed powershell formatting on linux/windows, env vars have to be set in term tho

This commit is contained in:
2026-08-30 17:06:14 +02:00
parent acf072e634
commit 5b0b6f32c5
10 changed files with 125 additions and 114 deletions
+3 -5
View File
@@ -14,11 +14,9 @@ autocmd("VimLeave", {
})
autocmd("BufWritePre", {
callback = function()
local ok = pcall(function()
vim.cmd "undojoin"
end)
vim.cmd "Neoformat"
pattern = "*",
callback = function(args)
require("conform").format({ bufnr = args.buf })
end,
})
+18
View File
@@ -0,0 +1,18 @@
require("conform").setup {
formatters_by_ft = {
lua = { "stylua" },
python = { "ruff" },
rust = { "rustfmt" },
javascript = { "prettier" },
typescript = { "prettier" },
qml = { "qmlformat" },
go = { "gofmt" },
sh = { "shfmt" },
bash = { "shfmt" },
zsh = { "shfmt" },
ps1 = {},
},
format_on_save = {
lsp_fallback = true,
},
}
+25 -5
View File
@@ -21,14 +21,13 @@ local capabilities =
vim.tbl_deep_extend("force", {}, vim.lsp.protocol.make_client_capabilities(), cmp_lsp.default_capabilities())
require("fidget").setup {}
require("mason").setup()
require("mason-lspconfig").setup {
automatic_enable = true,
automatic_enable = false,
ensure_installed = {
"lua_ls",
"qmlls",
"rust_analyzer",
"gopls",
"powershell_es",
},
handlers = {
function(server_name) -- default handler (optional)
@@ -51,6 +50,26 @@ require("mason-lspconfig").setup {
}
end,
["powershell_es"] = function()
local lspconfig = require "lspconfig"
lspconfig.powershell_es.setup {
capabilities = capabilities,
}
end,
["rust_analyzer"] = function()
local lspconfig = require "lspconfig"
lspconfig.rust_analyzer.setup {
capabilities = capabilities,
settings = {
["rust-analyzer"] = {
cargo = { allFeatures = true },
checkOnSave = { command = "clippy" },
},
},
}
end,
zls = function()
local lspconfig = require "lspconfig"
lspconfig.zls.setup {
@@ -67,6 +86,7 @@ require("mason-lspconfig").setup {
vim.g.zig_fmt_parse_errors = 0
vim.g.zig_fmt_autosave = 0
end,
["lua_ls"] = function()
local lspconfig = require "lspconfig"
lspconfig.lua_ls.setup {
@@ -265,7 +285,7 @@ local servers = {
"sourcekit",
"qmlls",
"tailwindcss",
"systemd-lsp",
-- "systemd-lsp",
require("mason-lspconfig").get_installed_servers(),
}
@@ -273,7 +293,7 @@ local flat_servers = flatten_to_array(servers)
for _, server in ipairs(flat_servers) do
lspconfig(server, {
on_attach = function(client, bufnr)
on_attach = function(client)
if client.name == "typos_lsp" or client.name == "copilot" then
return
end
-20
View File
@@ -1,20 +0,0 @@
local M = {}
M.plugin = {
"sbdchd/neoformat",
config = function()
vim.g.neoformat_enabled_lua = { "luaformatter" }
vim.g.neoformat_enabled_python = { "black" }
vim.g.neoformat_enabled_javascript = { "prettier" }
vim.g.neoformat_enabled_typescript = { "prettier" }
vim.g.neoformat_enabled_qml = { "qmlformat" }
vim.g.neoformat_enabled_go = { "gofmt" }
vim.g.neoformat_enabled_sh = { "shfmt" }
vim.g.neoformat_enabled_bash = { "shfmt" }
vim.g.neoformat_enabled_zsh = { "shfmt" }
vim.g.neoformat_enabled_rust = { "rustfmt" }
vim.g.neoformat_enabled_ps1 = { "pwshfmt" }
end,
}
return M
+10 -10
View File
@@ -6,19 +6,19 @@ local function pick(light, dark)
end
local c = {
bg = "#141219",
bg_alt = "#1C1B21",
bg_mid = pick("#2B2930", "#201F25"),
fg = "#E6E0EA",
fg_muted = "#CAC4D4",
bg = "#121318",
bg_alt = "#1A1B20",
bg_mid = pick("#292A2F", "#1E1F25"),
fg = "#E3E2E9",
fg_muted = "#C4C6D3",
fg_strong = pick("#15161A", "#F4F4F8"),
normal = "#5840A7",
insert = "#4A4169",
visual = "#882F73",
normal = "#718EDF",
insert = "#3E4867",
visual = "#C177BE",
replace = "#93000A",
command = pick("#FFDCF2", "#9FA8D8"),
inactive = "#1C1B21",
command = pick("#FFDCF2", "#90ACD5"),
inactive = "#1A1B20",
normal_fg = pick("#15161A", "#F4F4F8"),
insert_fg = pick("#15161A", "#F4F4F8"),
+12 -1
View File
@@ -11,13 +11,24 @@ map("n", "<C-a>", "ggVG", { noremap = true, silent = true })
map("n", "<C-j>", "<C-d>zz")
map("n", "<C-k>", "<C-u>zz")
map("n", "<A-->", ":bdelete<CR>")
map("", "=", function()
require("conform").format({ async = true, lsp_fallback = true }, function(err)
if not err then
local mode = vim.api.nvim_get_mode().mode
if vim.startswith(string.lower(mode), "v") then
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
end
end
end)
end, { desc = "Format code" })
-- map("n", "<SA-->", ":BufferRestore<CR>")
map("n", "<leader>e", function()
Snacks.explorer()
end)
map("n", "<leader>g", require("telescope.builtin").live_grep, { desc = "Telescope grep" })
map("n", "<leader>f", require("telescope.builtin").find_files, { desc = "Telescope find files" })
map('n', '<leader>u', require('undotree').toggle, { noremap = true, silent = true })
map("n", "<leader>u", require("undotree").toggle, { noremap = true, silent = true })
-- Copilot Chat buffer
map("n", "<A-c>", vim.cmd.CopilotChatToggle)
+2 -5
View File
@@ -15,12 +15,9 @@ return {
-- lazy = false,
},
{
"sbdchd/neoformat",
"stevearc/conform.nvim",
config = function()
require "config.format.neoformat"
require "config.format.conform"
end,
-- init = function()
-- vim.cmd("source" .. vim.fn.stdpath "config" .. "/lua/config/test.vim")
-- end,
},
}
-1
View File
@@ -102,7 +102,6 @@ return {
},
{
"mason-org/mason-lspconfig.nvim",
opts = {},
dependencies = {
{ "mason-org/mason.nvim", opts = {} },
"neovim/nvim-lspconfig",