1 Commits

Author SHA1 Message Date
orip
f27810d1bd Fix treesitter indents
Thanks @jackHerby for the report
fixes #1995
2026-04-15 03:44:17 +03:00

View File

@@ -616,8 +616,6 @@ require('lazy').setup({
-- Special Lua Config, as recommended by neovim help docs
lua_ls = {
on_init = function(client)
client.server_capabilities.documentFormattingProvider = false -- Disable formatting (formatting is done by stylua)
if client.workspace_folders then
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
@@ -639,11 +637,8 @@ require('lazy').setup({
},
})
end,
---@type lspconfig.settings.lua_ls
settings = {
Lua = {
format = { enable = false }, -- Disable formatting (formatting is done by stylua)
},
Lua = {},
},
},
}
@@ -676,7 +671,7 @@ require('lazy').setup({
keys = {
{
'<leader>f',
function() require('conform').format { async = true } end,
function() require('conform').format { async = true, lsp_format = 'fallback' } end,
mode = '',
desc = '[F]ormat buffer',
},
@@ -686,23 +681,21 @@ require('lazy').setup({
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
-- You can specify filetypes to autoformat on save here:
local enabled_filetypes = {
-- lua = true,
-- python = true,
}
if enabled_filetypes[vim.bo[bufnr].filetype] then
return { timeout_ms = 500 }
else
-- 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 }
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
return {
timeout_ms = 500,
lsp_format = 'fallback',
}
end
end,
default_format_opts = {
lsp_format = 'fallback', -- Use LSP formatting if available, otherwise use external formatters. Set to `false` to disable LSP formatting.
},
-- You can also specify external formatters in here.
formatters_by_ft = {
-- rust = { 'rustfmt' },
lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
@@ -900,7 +893,7 @@ require('lazy').setup({
-- check if treesitter indentation is available for this language, and if so enable it
-- in case there is no indent query, the indentexpr will fallback to the vim's built in one
local has_indent_query = vim.treesitter.query.get(language, 'indent') ~= nil
local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil
-- enables treesitter based indentation
if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end