diff --git a/autoload/neoformat/formatters/pwsh.vim b/autoload/neoformat/formatters/pwsh.vim new file mode 100644 index 0000000..2385d23 --- /dev/null +++ b/autoload/neoformat/formatters/pwsh.vim @@ -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 diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua new file mode 100644 index 0000000..85fbc7d --- /dev/null +++ b/ftplugin/rust.lua @@ -0,0 +1,18 @@ +local bufnr = vim.api.nvim_get_current_buf() +vim.keymap.set( + "n", + "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 } +) diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 87d71a6..e3a339d 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -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", { diff --git a/lua/config/format/neoformat.lua b/lua/config/format/neoformat.lua index cef3d24..6a352ab 100644 --- a/lua/config/format/neoformat.lua +++ b/lua/config/format/neoformat.lua @@ -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, } diff --git a/lua/config/format/prettier.lua b/lua/config/format/prettier.lua index d96c585..8ab81cc 100644 --- a/lua/config/format/prettier.lua +++ b/lua/config/format/prettier.lua @@ -11,6 +11,7 @@ prettier.setup({ "json", "less", "markdown", + "rust", "scss", "typescript", "typescriptreact", diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua index 1b2ecb0..251f93a 100644 --- a/lua/plugins/formatter.lua +++ b/lua/plugins/formatter.lua @@ -9,4 +9,9 @@ return { ---@type render.md.UserConfig opts = require "config.format.markdown", }, + { + 'mrcjkb/rustaceanvim', + version = '^9', + -- lazy = false, + }, } diff --git a/scripts/fWindows.ps1 b/scripts/fWindows.ps1 index 47d63f8..c5eaf00 100644 --- a/scripts/fWindows.ps1 +++ b/scripts/fWindows.ps1 @@ -15,7 +15,8 @@ $packages = @( "GNU.Wget2", "GnuWin32.UnZip", "GnuWin32.Gzip", - "7zip.7zip" + "7zip.7zip", + "PSScriptAnalyzer" ) for ($i = 0; $i -lt $packages.Count; $i++) {