added conform
This commit is contained in:
parent
e1ade38e04
commit
8966af7289
27
lua/plugins/conform.lua
Normal file
27
lua/plugins/conform.lua
Normal file
@ -0,0 +1,27 @@
|
||||
return {
|
||||
'stevearc/conform.nvim',
|
||||
cmd = { 'ConformInfo' },
|
||||
opts = {
|
||||
default_format_opts = {
|
||||
lsp_format = 'fallback',
|
||||
},
|
||||
log_level = vim.log.levels.ERROR,
|
||||
formatters_by_ft = {
|
||||
lua = { 'stylua' },
|
||||
python = { 'ruff_format' },
|
||||
yaml = { 'yamlfmt' },
|
||||
cmake = { 'gersemi' },
|
||||
markdown = { 'prettier' },
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
'<space>f',
|
||||
mode = { 'n', 'x', 'v' },
|
||||
function()
|
||||
require('conform').format()
|
||||
end,
|
||||
desc = 'Format with Conform',
|
||||
},
|
||||
},
|
||||
}
|
@ -1,43 +1,5 @@
|
||||
local M = {}
|
||||
|
||||
local efm_setup = function(lspconfig, capabilities, on_attach)
|
||||
local prettier = require('efmls-configs.formatters.prettier')
|
||||
local gersemi = require('efmls-configs.formatters.gersemi')
|
||||
local black = require('efmls-configs.formatters.black')
|
||||
local isort = require('efmls-configs.formatters.isort')
|
||||
local cmake_lint = require('efmls-configs.linters.cmake_lint')
|
||||
local flake8 = require('efmls-configs.linters.flake8')
|
||||
local yamlfmt = {
|
||||
command = require('mason-core.path').bin_prefix('yamlfmt') .. ' -',
|
||||
formatStdin = true,
|
||||
rootMarkers = { '.yamlfmt' },
|
||||
prefix = 'yamlfmt'
|
||||
}
|
||||
local languages = {
|
||||
markdown = { prettier },
|
||||
cmake = { gersemi, cmake_lint },
|
||||
yaml = {
|
||||
prettier,
|
||||
-- yamlfmt
|
||||
}
|
||||
}
|
||||
|
||||
local efmls_config = {
|
||||
filetypes = vim.tbl_keys(languages),
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
cmd = { require('mason-core.path').bin_prefix('efm-langserver') },
|
||||
settings = {
|
||||
rootMarkers = { '.git/' },
|
||||
languages = languages,
|
||||
},
|
||||
init_options = {
|
||||
documentFormatting = true,
|
||||
documentRangeFormatting = true,
|
||||
},
|
||||
}
|
||||
lspconfig.efm.setup(efmls_config)
|
||||
end
|
||||
|
||||
M.setup_server = function(lspconfig, capabilities, on_attach)
|
||||
-- lspconfig['pyright'].setup {
|
||||
@ -176,7 +138,6 @@ M.setup_server = function(lspconfig, capabilities, on_attach)
|
||||
lspconfig.neocmake.setup({})
|
||||
end
|
||||
|
||||
efm_setup(lspconfig, capabilities, on_attach)
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -27,17 +27,6 @@ local lspKeys = function(client, bufnr)
|
||||
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>',
|
||||
vim.tbl_extend('error', options, { desc = 'Switch Source/Header' }))
|
||||
|
||||
-- Set some keybinds conditional on server capabilities
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
vim.keymap.set('n', '<space>f', function()
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end, { noremap = true, silent = false, desc = 'Format file', buffer = bufnr })
|
||||
end
|
||||
if client.server_capabilities.documentRangeFormattingProvider then
|
||||
vim.keymap.set('x', '<space>f', function()
|
||||
vim.lsp.buf.format({ timeout_ms = 10000 })
|
||||
end, { noremap = true, silent = false, desc = 'Format visual', buffer = bufnr })
|
||||
end
|
||||
if client.supports_method('inlayHintProvider') then
|
||||
vim.keymap.set('n', '<space>i', function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })
|
||||
|
Loading…
x
Reference in New Issue
Block a user