@@ -95,12 +95,12 @@ function M.add_autocmds_to_buffer(augroup, bufnr, autocmds)
9595 end
9696end
9797
98- --- Apply default settings for diagnostics, formatting, and lsp capabilities .
99- --- It only need to be executed once, normally on mason-lspconfig.
100- --- @return nil
101- M . apply_default_lsp_settings = function ()
102- -- Icons
103- -- Apply the icons defined in ../icons/icons.lua
98+ --- This function define and apply the default NormalNvim diagnostic settings .
99+ ---
100+ --- Feel free to edit this function (but you shouldn't need to).
101+ --- @return table # A table with hover_opts, or empty table {}.
102+ M . apply_lsp_diagnostic_defaults = function ()
103+ -- Apply the icons defined in ../icons/icons.lu
104104 local signs = {
105105 { name = " DiagnosticSignError" , text = M .get_icon (" DiagnosticError" ), texthl = " DiagnosticSignError" },
106106 { name = " DiagnosticSignWarn" , text = M .get_icon (" DiagnosticWarn" ), texthl = " DiagnosticSignWarn" },
@@ -116,9 +116,6 @@ M.apply_default_lsp_settings = function()
116116 vim .fn .sign_define (sign .name , sign )
117117 end
118118
119- -- Apply default lsp hover borders
120- -- Applies the option lsp_round_borders_enabled from ../1-options.lua
121- local lsp_hover_opts = vim .g .lsp_round_borders_enabled and { border = " rounded" , silent = true } or {}
122119
123120 -- Set default diagnostics
124121 local default_diagnostics = {
@@ -145,9 +142,7 @@ M.apply_default_lsp_settings = function()
145142 },
146143 }
147144
148- -- TODO: This is the only point where we are actually 'applying something' → Let's move it away.
149- -- Apply default diagnostics
150- -- Applies the option diagnostics_mode from ../1-options.lua
145+ -- Table of available options to be used in ../1-options.lua > vim.g.diagnostics_mode
151146 local diagnostics = {
152147 -- diagnostics off
153148 [0 ] = vim .tbl_deep_extend (
@@ -164,27 +159,29 @@ M.apply_default_lsp_settings = function()
164159 }
165160 vim .diagnostic .config (diagnostics [vim .g .diagnostics_mode ])
166161
167- -- Apply formatting settings
168- local lsp_formatting = { format_on_save = { enabled = true }, disabled = {} }
169- if type (lsp_formatting .format_on_save ) == " boolean" then
170- lsp_formatting .format_on_save = { enabled = lsp_formatting .format_on_save }
171- end
172- local lsp_format_opts = vim .deepcopy (lsp_formatting )
173- lsp_format_opts .disabled = nil
174- lsp_format_opts .format_on_save = nil
162+ -- Get the option lsp_round_borders_enabled from ../1-options.lua
163+ local lsp_hover_opts = vim .g .lsp_round_borders_enabled and { border = " rounded" , silent = true } or {}
164+
165+ return lsp_hover_opts
166+ end
167+
168+ --- This function define the default NormalNvim formatting settings.
169+ --- It's suppossed to be called on the mappings file.
170+ ---
171+ --- Feel free to edit this function (but you should't need to).
172+ --- @return table # A table with hover_opts, or empty table {}.
173+ M .get_lsp_formatting_defaults = function ()
174+ -- Set formatting setting
175+ local lsp_format_opts = { format_on_save = { enabled = vim .g .autoformat_enabled or false }, disabled = {} }
176+
177+ -- Check if client is fully disabled or filtered by function
175178 lsp_format_opts .filter = function (client )
176- local filter = lsp_formatting .filter
177- local disabled = lsp_formatting .disabled or {}
178- -- check if client is fully disabled or filtered by function
179+ local filter = lsp_format_opts .filter
180+ local disabled = lsp_format_opts .disabled
179181 return not (vim .tbl_contains (disabled , client .name ) or (type (filter ) == " function" and not filter (client )))
180182 end
181183
182- local lsp_default_opts = {}
183- lsp_default_opts .formatting = lsp_formatting
184- lsp_default_opts .format_opts = lsp_format_opts
185- lsp_default_opts .hover_opts = lsp_hover_opts
186-
187- return lsp_default_opts
184+ return lsp_format_opts
188185end
189186
190187--- Applies the user lsp mappings to the lsp client.
0 commit comments