nvim/lsp: move out non-lsp formatting bindings

This commit is contained in:
Primrose 2025-07-09 10:30:50 +02:00
parent a644f3c688
commit ce5e5610e1
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
4 changed files with 19 additions and 26 deletions

View file

@ -0,0 +1,5 @@
vim.keymap.set("n", "<leader>f", function()
local saved = vim.fn.winsaveview()
vim.cmd([[silent exec "%!shfmt"]])
vim.fn.winrestview(saved)
end, { desc = "ft(bash): Format with shfmt" })

View file

@ -0,0 +1,6 @@
vim.keymap.set("n", "<leader>f", function()
local saved = vim.fn.winsaveview()
vim.cmd([[silent exec "!stylua %"]])
vim.fn.winrestview(saved)
end, { desc = "ft(lua): Format with stylua" })

View file

@ -1,3 +1,9 @@
vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
vim.bo.textwidth = 100
vim.keymap.set("n", "<leader>f", function()
local saved = vim.fn.winsaveview()
vim.cmd([[silent exec "%!typstyle -c 100"]])
vim.fn.winrestview(saved)
end, { desc = "ft(typst): Format with typstyle" })

View file

@ -28,35 +28,11 @@ local servers = {
-- golangci_lint_ls = {},
fish_lsp = {},
bashls = {},
bashls = { -- Bash
on_attach = function(_, bufno)
map("n", "<leader>f", function()
local saved = vim.fn.winsaveview()
vim.cmd([[silent exec "%!shfmt"]])
vim.fn.winrestview(saved)
end, { buffer = bufno })
end,
},
tinymist = {
on_attach = function(_, bufno)
map("n", "<leader>f", function()
local saved = vim.fn.winsaveview()
vim.cmd([[silent exec "%!typstyle -c 100"]])
vim.fn.winrestview(saved)
end, { buffer = bufno })
end,
},
tinymist = {},
lua_ls = { -- Lua
on_attach = function(_, bufno)
map("n", "<leader>f", function()
local saved = vim.fn.winsaveview()
vim.cmd([[silent exec "!stylua %"]])
vim.fn.winrestview(saved)
end, { buffer = bufno })
end,
settings = {
Lua = {
workspace = {