mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-09 22:51:25 +00:00
chore(nvim): fixed mason formatters, config
This commit is contained in:
@@ -104,15 +104,4 @@ autocmd({ 'BufRead', 'BufNewFile' }, {
|
|||||||
command = 'set filetype=sshconfig',
|
command = 'set filetype=sshconfig',
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Format on save, unless disabled
|
|
||||||
autocmd('BufWritePre', {
|
|
||||||
group = augroup('Format', { clear = true }),
|
|
||||||
pattern = '*', -- All files
|
|
||||||
callback = function()
|
|
||||||
if not vim.g.disable_autoformat then
|
|
||||||
vim.lsp.buf.format({ async = false })
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|||||||
@@ -20,8 +20,16 @@ K.n('<C-w>+', ':resize +10<CR>', { desc = 'H Resize +' })
|
|||||||
K.n('<C-w>=', '<C-w>=', { desc = 'Equal Size Splits' })
|
K.n('<C-w>=', '<C-w>=', { desc = 'Equal Size Splits' })
|
||||||
|
|
||||||
-- ── Deal with word wrap ─────────────────────────────────────────────
|
-- ── Deal with word wrap ─────────────────────────────────────────────
|
||||||
K.n('k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Move up', noremap = true, expr = true })
|
K.n(
|
||||||
K.n('j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Move down', noremap = true, expr = true })
|
'k',
|
||||||
|
"v:count == 0 ? 'gk' : 'k'",
|
||||||
|
{ desc = 'Move up', noremap = true, expr = true }
|
||||||
|
)
|
||||||
|
K.n(
|
||||||
|
'j',
|
||||||
|
"v:count == 0 ? 'gj' : 'j'",
|
||||||
|
{ desc = 'Move down', noremap = true, expr = true }
|
||||||
|
)
|
||||||
|
|
||||||
-- ── Text manipulation ───────────────────────────────────────────────
|
-- ── Text manipulation ───────────────────────────────────────────────
|
||||||
K.d('<', { 'n', 'v' }, '<gv', 'Indent Left')
|
K.d('<', { 'n', 'v' }, '<gv', 'Indent Left')
|
||||||
@@ -55,7 +63,7 @@ K.ld('ca', 'n', ':Lspsaga code_action<cr>', 'Code Action')
|
|||||||
K.ld('cci', 'n', ':Lspsaga incoming_calls<cr>', 'Incoming Calls')
|
K.ld('cci', 'n', ':Lspsaga incoming_calls<cr>', 'Incoming Calls')
|
||||||
K.ld('cco', 'n', ':Lspsaga outgoing_calls<cr>', 'Outgoing Calls')
|
K.ld('cco', 'n', ':Lspsaga outgoing_calls<cr>', 'Outgoing Calls')
|
||||||
K.ld('cd', 'n', ':Lspsaga show_line_diagnostics<cr>', 'Line Diagnostics')
|
K.ld('cd', 'n', ':Lspsaga show_line_diagnostics<cr>', 'Line Diagnostics')
|
||||||
K.ld('cf', { 'n', 'x' }, ':lua vim.lsp.buf.format()<CR>', 'Format')
|
-- K.ld('cf', { 'n', 'x' }, ':lua vim.lsp.buf.format()<CR>', 'Format')
|
||||||
K.ld('cg', 'n', ':lua require("neogen").generate()<CR>', 'Generate annotations')
|
K.ld('cg', 'n', ':lua require("neogen").generate()<CR>', 'Generate annotations')
|
||||||
K.ld('ci', 'n', ':Lspsaga implement<cr>', 'Implementations')
|
K.ld('ci', 'n', ':Lspsaga implement<cr>', 'Implementations')
|
||||||
K.ld('cl', 'n', ':Lspsaga show_cursor_diagnostics<cr>', 'Cursor Diagnostics')
|
K.ld('cl', 'n', ':Lspsaga show_cursor_diagnostics<cr>', 'Cursor Diagnostics')
|
||||||
@@ -84,14 +92,18 @@ K.nl('cbt', '<Cmd>CBllline<CR>', 'CB: Titled Line')
|
|||||||
-- unless it's a generic operation like searching or finding buffers
|
-- unless it's a generic operation like searching or finding buffers
|
||||||
K.nl('f', ':Telescope find_files<cr>', 'Find Files')
|
K.nl('f', ':Telescope find_files<cr>', 'Find Files')
|
||||||
K.nl(',', ':Telescope buffers<cr>', 'Find existing buffers')
|
K.nl(',', ':Telescope buffers<cr>', 'Find existing buffers')
|
||||||
K.nl('/', function()
|
K.nl(
|
||||||
require('telescope.builtin').current_buffer_fuzzy_find(
|
'/',
|
||||||
require('telescope.themes').get_dropdown {
|
function()
|
||||||
winblend = 20,
|
require('telescope.builtin').current_buffer_fuzzy_find(
|
||||||
previewer = true,
|
require('telescope.themes').get_dropdown {
|
||||||
}
|
winblend = 20,
|
||||||
)
|
previewer = true,
|
||||||
end, 'Fuzzily search in current buffer')
|
}
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
'Fuzzily search in current buffer'
|
||||||
|
)
|
||||||
|
|
||||||
K.nl('sc', ':Telescope commands<cr>', 'Commands')
|
K.nl('sc', ':Telescope commands<cr>', 'Commands')
|
||||||
K.nl('sd', ':Telescope diagnostics<cr>', 'Search Diagnostics')
|
K.nl('sd', ':Telescope diagnostics<cr>', 'Search Diagnostics')
|
||||||
@@ -100,7 +112,11 @@ K.nl('sh', ':Telescope help_tags<cr>', 'Help tags')
|
|||||||
K.nl('sk', ':Telescope keymaps<cr>', 'Search Keymaps')
|
K.nl('sk', ':Telescope keymaps<cr>', 'Search Keymaps')
|
||||||
K.nl('sl', ':Telescope luasnip<CR>', 'Search LuaSnip')
|
K.nl('sl', ':Telescope luasnip<CR>', 'Search LuaSnip')
|
||||||
K.nl('so', ':Telescope oldfiles<CR>', 'Old Files')
|
K.nl('so', ':Telescope oldfiles<CR>', 'Old Files')
|
||||||
K.nl('sp', ':lua require("telescope").extensions.lazy_plugins.lazy_plugins()<cr>', 'Lazy Plugins')
|
K.nl(
|
||||||
|
'sp',
|
||||||
|
':lua require("telescope").extensions.lazy_plugins.lazy_plugins()<cr>',
|
||||||
|
'Lazy Plugins'
|
||||||
|
)
|
||||||
K.nl('sq', ':Telescope quickfix<cr>', 'Quickfix')
|
K.nl('sq', ':Telescope quickfix<cr>', 'Quickfix')
|
||||||
K.nl('ss', ':Telescope treesitter<cr>', 'Treesitter')
|
K.nl('ss', ':Telescope treesitter<cr>', 'Treesitter')
|
||||||
K.nl('st', ':TodoTelescope<cr>', 'Search Todos')
|
K.nl('st', ':TodoTelescope<cr>', 'Search Todos')
|
||||||
|
|||||||
@@ -1,4 +1,129 @@
|
|||||||
|
-- ╭─────────────────────────────────────────────────────────╮
|
||||||
|
-- │ LSP Setup and configuration │
|
||||||
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
-- LSP Servers are installed and configured by lsp-setup.nvim
|
||||||
|
-- Mason formatters Conform uses to format files
|
||||||
|
-- These are automatically configured by zapling/mason-conform.nvim
|
||||||
|
|
||||||
|
local lsp_servers = {
|
||||||
|
bashls = {},
|
||||||
|
-- csharp_ls = {},
|
||||||
|
diagnosticls = {},
|
||||||
|
gopls = {
|
||||||
|
settings = {
|
||||||
|
gopls = {
|
||||||
|
hints = {
|
||||||
|
rangeVariableTypes = true,
|
||||||
|
parameterNames = true,
|
||||||
|
constantValues = true,
|
||||||
|
assignVariableTypes = true,
|
||||||
|
compositeLiteralFields = true,
|
||||||
|
compositeLiteralTypes = true,
|
||||||
|
functionTypeParameters = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
html = {},
|
||||||
|
intelephense = {},
|
||||||
|
jsonls = {},
|
||||||
|
lua_ls = {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
completion = {
|
||||||
|
callSnippet = 'Replace',
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
globals = {
|
||||||
|
'vim',
|
||||||
|
-- busted
|
||||||
|
'describe',
|
||||||
|
'it',
|
||||||
|
'before_each',
|
||||||
|
'after_each',
|
||||||
|
'assert',
|
||||||
|
},
|
||||||
|
disable = {
|
||||||
|
-- Ignore lua_ls noisy `missing-fields` warnings
|
||||||
|
'missing-fields',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hint = {
|
||||||
|
enable = false,
|
||||||
|
arrayIndex = 'Auto',
|
||||||
|
await = true,
|
||||||
|
paramName = 'All',
|
||||||
|
paramType = true,
|
||||||
|
semicolon = 'SameLine',
|
||||||
|
setType = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tailwindcss = {},
|
||||||
|
ts_ls = {
|
||||||
|
settings = {
|
||||||
|
typescript = {
|
||||||
|
inlayHints = {
|
||||||
|
includeInlayParameterNameHints = 'all',
|
||||||
|
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||||
|
includeInlayFunctionParameterTypeHints = true,
|
||||||
|
includeInlayVariableTypeHints = true,
|
||||||
|
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
|
||||||
|
includeInlayPropertyDeclarationTypeHints = true,
|
||||||
|
includeInlayFunctionLikeReturnTypeHints = true,
|
||||||
|
includeInlayEnumMemberValueHints = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
vimls = {},
|
||||||
|
volar = {
|
||||||
|
settings = {
|
||||||
|
typescript = {
|
||||||
|
inlayHints = {
|
||||||
|
enumMemberValues = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
functionLikeReturnTypes = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
propertyDeclarationTypes = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
parameterTypes = {
|
||||||
|
enabled = true,
|
||||||
|
suppressWhenArgumentMatchesName = true,
|
||||||
|
},
|
||||||
|
variableTypes = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
|
||||||
|
-- used for completion, annotations and signatures of Neovim apis
|
||||||
|
-- https://github.com/folke/lazydev.nvim
|
||||||
|
{
|
||||||
|
'folke/lazydev.nvim',
|
||||||
|
ft = 'lua',
|
||||||
|
opts = {
|
||||||
|
library = {
|
||||||
|
-- Load luvit types when the `vim.uv` word is found
|
||||||
|
{ path = 'luvit-meta/library', words = { 'vim%.uv' } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Meta type definitions for the Lua platform Luvit.
|
||||||
|
-- https://github.com/Bilal2453/luvit-meta
|
||||||
|
{ 'Bilal2453/luvit-meta', lazy = true },
|
||||||
|
|
||||||
-- improve neovim lsp experience
|
-- improve neovim lsp experience
|
||||||
-- https://github.com/nvimdev/lspsaga.nvim
|
-- https://github.com/nvimdev/lspsaga.nvim
|
||||||
-- https://nvimdev.github.io/lspsaga/
|
-- https://nvimdev.github.io/lspsaga/
|
||||||
@@ -24,21 +149,72 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- A simple wrapper for nvim-lspconfig and mason-lspconfig
|
-- A simple wrapper for nvim-lspconfig and mason-lspconfig
|
||||||
-- to easily setup LSP servers.
|
-- to easily setup LSP servers.
|
||||||
-- https://github.com/junnplus/lsp-setup.nvim
|
-- https://github.com/junnplus/lsp-setup.nvim
|
||||||
{
|
{
|
||||||
'junnplus/lsp-setup.nvim',
|
'junnplus/lsp-setup.nvim',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
-- Quickstart configs for Nvim LSP
|
||||||
|
-- https://github.com/neovim/nvim-lspconfig
|
||||||
{ 'neovim/nvim-lspconfig' },
|
{ 'neovim/nvim-lspconfig' },
|
||||||
|
|
||||||
|
-- Portable package manager for Neovim that runs everywhere Neovim runs.
|
||||||
|
-- Easily install and manage LSP servers, DAP servers, linters, and formatters.
|
||||||
|
-- https://github.com/williamboman/mason.nvim
|
||||||
{
|
{
|
||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim',
|
||||||
|
version = '*',
|
||||||
cmd = 'Mason',
|
cmd = 'Mason',
|
||||||
run = ':MasonUpdate'
|
run = ':MasonUpdate',
|
||||||
|
opts = {},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- Extensible UI for Neovim notifications and LSP progress messages.
|
||||||
|
-- https://github.com/j-hui/fidget.nvim
|
||||||
|
{
|
||||||
|
'j-hui/fidget.nvim',
|
||||||
|
version = '*',
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Extension to mason.nvim that makes it easier to use lspconfig with mason.nvim.
|
||||||
|
-- https://github.com/williamboman/mason-lspconfig.nvim
|
||||||
{ 'williamboman/mason-lspconfig.nvim' },
|
{ 'williamboman/mason-lspconfig.nvim' },
|
||||||
{ 'folke/neodev.nvim' },
|
|
||||||
|
-- Install and upgrade third party tools automatically
|
||||||
|
-- https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim
|
||||||
|
{
|
||||||
|
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||||
|
version = '*',
|
||||||
|
opts = {
|
||||||
|
auto_install = true,
|
||||||
|
auto_update = true,
|
||||||
|
ensure_installed = {
|
||||||
|
'editorconfig-checker',
|
||||||
|
'goimports',
|
||||||
|
'gotests',
|
||||||
|
'phpcbf',
|
||||||
|
'pint',
|
||||||
|
'prettierd',
|
||||||
|
'shellcheck',
|
||||||
|
'shfmt',
|
||||||
|
'staticcheck',
|
||||||
|
'stylua',
|
||||||
|
'vint',
|
||||||
|
'yamlfmt',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- JSON schemas for Neovim
|
||||||
|
-- https://github.com/b0o/SchemaStore.nvim
|
||||||
{ 'b0o/schemastore.nvim' },
|
{ 'b0o/schemastore.nvim' },
|
||||||
|
|
||||||
|
-- Performant, batteries-included completion plugin for Neovim
|
||||||
|
-- https://github.com/saghen/blink.cmp
|
||||||
|
-- See lua/plugins/blink.lua for configs
|
||||||
{ 'saghen/blink.cmp' },
|
{ 'saghen/blink.cmp' },
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
@@ -51,126 +227,45 @@ return {
|
|||||||
inlay_hints = {
|
inlay_hints = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
},
|
},
|
||||||
servers = {
|
servers = lsp_servers,
|
||||||
bashls = {},
|
|
||||||
-- csharp_ls = {},
|
|
||||||
diagnosticls = {},
|
|
||||||
gopls = {
|
|
||||||
settings = {
|
|
||||||
gopls = {
|
|
||||||
hints = {
|
|
||||||
rangeVariableTypes = true,
|
|
||||||
parameterNames = true,
|
|
||||||
constantValues = true,
|
|
||||||
assignVariableTypes = true,
|
|
||||||
compositeLiteralFields = true,
|
|
||||||
compositeLiteralTypes = true,
|
|
||||||
functionTypeParameters = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
html = {},
|
|
||||||
intelephense = {},
|
|
||||||
jsonls = {},
|
|
||||||
lua_ls = {
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
diagnostics = {
|
|
||||||
globals = { 'vim' },
|
|
||||||
disable = {
|
|
||||||
-- Ignore lua_ls noisy `missing-fields` warnings
|
|
||||||
'missing-fields',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
hint = {
|
|
||||||
enable = false,
|
|
||||||
arrayIndex = 'Auto',
|
|
||||||
await = true,
|
|
||||||
paramName = 'All',
|
|
||||||
paramType = true,
|
|
||||||
semicolon = 'SameLine',
|
|
||||||
setType = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
tailwindcss = {},
|
|
||||||
ts_ls = {
|
|
||||||
settings = {
|
|
||||||
typescript = {
|
|
||||||
inlayHints = {
|
|
||||||
includeInlayParameterNameHints = 'all',
|
|
||||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
|
||||||
includeInlayFunctionParameterTypeHints = true,
|
|
||||||
includeInlayVariableTypeHints = true,
|
|
||||||
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
|
|
||||||
includeInlayPropertyDeclarationTypeHints = true,
|
|
||||||
includeInlayFunctionLikeReturnTypeHints = true,
|
|
||||||
includeInlayEnumMemberValueHints = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
vimls = {},
|
|
||||||
volar = {
|
|
||||||
settings = {
|
|
||||||
typescript = {
|
|
||||||
inlayHints = {
|
|
||||||
enumMemberValues = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
functionLikeReturnTypes = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
propertyDeclarationTypes = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
parameterTypes = {
|
|
||||||
enabled = true,
|
|
||||||
suppressWhenArgumentMatchesName = true,
|
|
||||||
},
|
|
||||||
variableTypes = {
|
|
||||||
enabled = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
require('neodev').setup()
|
require('lazydev').setup()
|
||||||
require('lsp-setup').setup(opts)
|
require('lsp-setup').setup(opts)
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require 'lspconfig'
|
||||||
for server, config in pairs(opts.servers) do
|
for server, config in pairs(opts.servers) do
|
||||||
-- passing config.capabilities to blink.cmp merges with the capabilities in your
|
-- passing config.capabilities to blink.cmp merges with the capabilities in your
|
||||||
-- `opts[server].capabilities, if you've defined it
|
-- `opts[server].capabilities, if you've defined it
|
||||||
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
config.capabilities =
|
||||||
|
require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
||||||
lspconfig[server].setup(config)
|
lspconfig[server].setup(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
lspconfig.lua_ls.on_init = function(client)
|
lspconfig.lua_ls.on_init = function(client)
|
||||||
if client.workspace_folders then
|
if client.workspace_folders then
|
||||||
local path = client.workspace_folders[1].name
|
local path = client.workspace_folders[1].name
|
||||||
if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
if
|
||||||
|
vim.loop.fs_stat(path .. '/.luarc.json')
|
||||||
|
or vim.loop.fs_stat(path .. '/.luarc.jsonc')
|
||||||
|
then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
client.config.settings.Lua =
|
||||||
runtime = {
|
vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||||
-- Tell the language server which version of Lua you're using
|
runtime = {
|
||||||
-- (most likely LuaJIT in the case of Neovim)
|
-- Tell the language server which version of Lua you're using
|
||||||
version = 'LuaJIT'
|
-- (most likely LuaJIT in the case of Neovim)
|
||||||
},
|
version = 'LuaJIT',
|
||||||
-- Make the server aware of Neovim runtime files
|
},
|
||||||
workspace = {
|
-- Make the server aware of Neovim runtime files
|
||||||
checkThirdParty = false,
|
workspace = {
|
||||||
library = {
|
checkThirdParty = false,
|
||||||
vim.env.VIMRUNTIME
|
library = {
|
||||||
}
|
vim.env.VIMRUNTIME,
|
||||||
}
|
},
|
||||||
})
|
},
|
||||||
|
})
|
||||||
end
|
end
|
||||||
lspconfig.jsonls.settings = {
|
lspconfig.jsonls.settings = {
|
||||||
json = {
|
json = {
|
||||||
@@ -191,4 +286,53 @@ return {
|
|||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- Lightweight yet powerful formatter plugin for Neovim
|
||||||
|
-- https://github.com/stevearc/conform.nvim
|
||||||
|
{
|
||||||
|
'stevearc/conform.nvim',
|
||||||
|
event = { 'BufWritePre' },
|
||||||
|
cmd = { 'ConformInfo' },
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
'<leader>cf',
|
||||||
|
function()
|
||||||
|
require('conform').format { async = true, lsp_format = 'fallback' }
|
||||||
|
end,
|
||||||
|
mode = '',
|
||||||
|
desc = 'Format buffer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
notify_on_error = false,
|
||||||
|
---@type nil|conform.FormatOpts|fun(bufnr: integer): nil|conform.FormatOpts
|
||||||
|
format_on_save = function(bufnr)
|
||||||
|
-- Disable "format_on_save lsp_fallback" for languages that don't
|
||||||
|
-- have a well standardized coding style. You can add additional
|
||||||
|
-- languages here or re-enable it for the disabled ones.
|
||||||
|
local disable_filetypes = { c = true, cpp = true }
|
||||||
|
local lsp_format_opt
|
||||||
|
if disable_filetypes[vim.bo[bufnr].filetype] then
|
||||||
|
lsp_format_opt = 'never'
|
||||||
|
else
|
||||||
|
lsp_format_opt = 'fallback'
|
||||||
|
end
|
||||||
|
return {
|
||||||
|
timeout_ms = 500,
|
||||||
|
lsp_format = lsp_format_opt,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
formatters_by_ft = {
|
||||||
|
lua = { 'stylua' },
|
||||||
|
-- Conform can also run multiple formatters sequentially
|
||||||
|
-- python = { "isort", "black" },
|
||||||
|
--
|
||||||
|
-- You can use 'stop_after_first' to run the first available formatter from the list
|
||||||
|
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- Automatically install formatters registered with conform.nvim via mason.nvim
|
||||||
|
-- https://github.com/zapling/mason-conform.nvim
|
||||||
|
{ 'zapling/mason-conform.nvim', opts = {} },
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user