mirror of
https://github.com/dam9000/kickstart-modular.nvim.git
synced 2026-05-14 08:23:48 +00:00
Use stylua as an lsp formatter instead of an external formatter
This commit is contained in:
parent
648471c9eb
commit
459b86865e
20
init.lua
20
init.lua
@ -616,6 +616,8 @@ require('lazy').setup({
|
|||||||
-- Special Lua Config, as recommended by neovim help docs
|
-- Special Lua Config, as recommended by neovim help docs
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
on_init = function(client)
|
on_init = function(client)
|
||||||
|
client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua)
|
||||||
|
|
||||||
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 path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
|
if path ~= vim.fn.stdpath 'config' and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) then return end
|
||||||
@ -637,8 +639,11 @@ require('lazy').setup({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
---@type lspconfig.settings.lua_ls
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {},
|
Lua = {
|
||||||
|
format = { enable = false }, -- Disable formatting (formatting is done by stylua)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -671,7 +676,7 @@ require('lazy').setup({
|
|||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
'<leader>f',
|
'<leader>f',
|
||||||
function() require('conform').format { async = true, lsp_format = 'fallback' } end,
|
function() require('conform').format { async = true } end,
|
||||||
mode = '',
|
mode = '',
|
||||||
desc = '[F]ormat buffer',
|
desc = '[F]ormat buffer',
|
||||||
},
|
},
|
||||||
@ -688,14 +693,15 @@ require('lazy').setup({
|
|||||||
if disable_filetypes[vim.bo[bufnr].filetype] then
|
if disable_filetypes[vim.bo[bufnr].filetype] then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
return {
|
return { timeout_ms = 500 }
|
||||||
timeout_ms = 500,
|
|
||||||
lsp_format = 'fallback',
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
default_format_opts = {
|
||||||
|
lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely.
|
||||||
|
},
|
||||||
|
-- You can also specify external formatters in here.
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { 'stylua' },
|
-- rust = { 'rustfmt' },
|
||||||
-- Conform can also run multiple formatters sequentially
|
-- Conform can also run multiple formatters sequentially
|
||||||
-- python = { "isort", "black" },
|
-- python = { "isort", "black" },
|
||||||
--
|
--
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user