Configuring formatter for Lua

This commit is contained in:
Eduardo Cueto-Mendoza 2023-08-07 12:59:29 +01:00
parent cc8d398753
commit d058cadf33
2 changed files with 53 additions and 20 deletions

View File

@ -1,9 +1,9 @@
require("lsp-format").setup {} require("lsp-format").setup {}
local on_attach = function(client) local on_attach = function(client)
require("lsp-format").on_attach(client) require("lsp-format").on_attach(client)
-- ... custom code ... -- ... custom code ...
end end
require("lspconfig").bashls.setup { on_attach = on_attach } require("lspconfig").bashls.setup { on_attach = on_attach }

View File

@ -6,24 +6,24 @@ end)
-- Language servers -- Language servers
if (MY_OS == 'Linux') then if (MY_OS == 'Linux') then
lsp.ensure_installed({ lsp.ensure_installed({
-- Replace these with whatever servers you want to install -- Replace these with whatever servers you want to install
'bashls', 'bashls',
'clangd', 'clangd',
'julials', 'julials',
'lua_ls', 'lua_ls',
'ltex', 'ltex',
'pylsp', 'pylsp',
'texlab', 'texlab',
'zls' 'zls'
}) })
elseif (MY_OS == 'FreeBSD') then elseif (MY_OS == 'FreeBSD') then
lsp.ensure_installed({ lsp.ensure_installed({
-- Replace these with whatever servers you want to install -- Replace these with whatever servers you want to install
'bashls', 'bashls',
'julials', 'julials',
'pylsp', 'pylsp',
}) })
end end
--[[ --[[
@ -41,7 +41,40 @@ require('lspconfig').clangd.setup({})
require('lspconfig').julials.setup({}) require('lspconfig').julials.setup({})
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls()) require('lspconfig').lua_ls.setup({
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { 'vim' },
neededFileStatus = {
["codestyle-check"] = "Any",
},
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
format = {
enable = true,
-- Put format options here
-- NOTE: the value should be STRING!!
defaultConfig = {
indent_style = "space",
indent_size = "4",
}
},
},
},
})
local path = vim.fn.stdpath("config") .. "/after/plugin/dictionary-gb.txt" local path = vim.fn.stdpath("config") .. "/after/plugin/dictionary-gb.txt"
local words = {} local words = {}