@@ -616,6 +616,8 @@ require('lazy').setup({
616616 -- Special Lua Config, as recommended by neovim help docs
617617 lua_ls = {
618618 on_init = function (client )
619+ client .server_capabilities .documentFormattingProvider = false -- Disable formatting (formatting is done by stylua)
620+
619621 if client .workspace_folders then
620622 local path = client .workspace_folders [1 ].name
621623 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({
637639 },
638640 })
639641 end ,
642+ --- @type lspconfig.settings.lua_ls
640643 settings = {
641- Lua = {},
644+ Lua = {
645+ format = { enable = false }, -- Disable formatting (formatting is done by stylua)
646+ },
642647 },
643648 },
644649 }
@@ -671,7 +676,7 @@ require('lazy').setup({
671676 keys = {
672677 {
673678 ' <leader>f' ,
674- function () require (' conform' ).format { async = true , lsp_format = ' fallback ' } end ,
679+ function () require (' conform' ).format { async = true } end ,
675680 mode = ' ' ,
676681 desc = ' [F]ormat buffer' ,
677682 },
@@ -688,14 +693,15 @@ require('lazy').setup({
688693 if disable_filetypes [vim .bo [bufnr ].filetype ] then
689694 return nil
690695 else
691- return {
692- timeout_ms = 500 ,
693- lsp_format = ' fallback' ,
694- }
696+ return { timeout_ms = 500 }
695697 end
696698 end ,
699+ default_format_opts = {
700+ lsp_format = ' fallback' , -- Use LSP formatting if available, otherwise use external formatters. Set to `false` to disable LSP formatting.
701+ },
702+ -- You can also specify external formatters in here.
697703 formatters_by_ft = {
698- lua = { ' stylua ' },
704+ -- rust = { 'rustfmt ' },
699705 -- Conform can also run multiple formatters sequentially
700706 -- python = { "isort", "black" },
701707 --
0 commit comments