pwsh & rustfmt

This commit is contained in:
2026-05-22 10:11:25 +02:00
parent ee4515da26
commit 91773e0a00
7 changed files with 59 additions and 8 deletions
+25
View File
@@ -0,0 +1,25 @@
function! neoformat#formatters#pwsh#enabled() abort
return ['pwshfmt']
endfunction
function! neoformat#formatters#pwsh#pwshfmt() abort
if has('win32') || has('win64')
let l:args = [
\ '-NoProfile',
\ '-Command',
\ 'Invoke-Formatter',
\ ]
else
let l:args = [
\ '-NoProfile',
\ '-Command',
\ '"Import-Module (Resolve-Path \"/opt/powershell-editor-services/PSScriptAnalyzer/*/PSScriptAnalyzer.psd1\" | Select-Object -ExpandProperty Path); Invoke-Formatter -ScriptDefinition (\$input | Out-String)"'
\ ]
endif
return {
\ 'exe': 'pwsh',
\ 'args': l:args,
\ 'stdin': 1,
\ }
endfunction
+18
View File
@@ -0,0 +1,18 @@
local bufnr = vim.api.nvim_get_current_buf()
vim.keymap.set(
"n",
"<leader>a",
function()
vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping
-- or vim.lsp.buf.codeAction() if you don't want grouping.
end,
{ silent = true, buffer = bufnr }
)
vim.keymap.set(
"n",
"K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions
function()
vim.cmd.RustLsp({'hover', 'actions'})
end,
{ silent = true, buffer = bufnr }
)
+6 -6
View File
@@ -1,12 +1,12 @@
local autocmd = vim.api.nvim_create_autocmd
autocmd("LspAttach", {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client then
vim.lsp.document_color.enable(false, { bufnr = args.buf })
end
end,
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client then
vim.lsp.document_color.enable(false, { bufnr = args.buf })
end
end,
})
autocmd("VimLeave", {
+2 -1
View File
@@ -12,7 +12,8 @@ M.plugin = {
vim.g.neoformat_enabled_sh = { "shfmt" }
vim.g.neoformat_enabled_bash = { "shfmt" }
vim.g.neoformat_enabled_zsh = { "shfmt" }
vim.g.neoformat_enabled_powershell = { "pwshfmt" } -- experimental
vim.g.neoformat_enabled_rust = { "rustfmt" }
vim.g.neoformat_enabled_pwsh = { "pwshfmt" }
end,
}
+1
View File
@@ -11,6 +11,7 @@ prettier.setup({
"json",
"less",
"markdown",
"rust",
"scss",
"typescript",
"typescriptreact",
+5
View File
@@ -9,4 +9,9 @@ return {
---@type render.md.UserConfig
opts = require "config.format.markdown",
},
{
'mrcjkb/rustaceanvim',
version = '^9',
-- lazy = false,
},
}
+2 -1
View File
@@ -15,7 +15,8 @@ $packages = @(
"GNU.Wget2",
"GnuWin32.UnZip",
"GnuWin32.Gzip",
"7zip.7zip"
"7zip.7zip",
"PSScriptAnalyzer"
)
for ($i = 0; $i -lt $packages.Count; $i++) {