chore: improve lsp formatting filtering

This commit is contained in:
Micah Halter
2022-10-07 11:27:44 -05:00
committed by Micah Halter
parent 571481f8af
commit 857546e5f6
3 changed files with 13 additions and 26 deletions
+1 -5
View File
@@ -24,8 +24,6 @@
AstroNvim is an aesthetic and feature-rich neovim config that is extensible and easy to use with a great set of plugins
</p>
**_Notice:_** AstroNvim v1.4.0 has added `stable` and `nightly` update channels. For the time being we have kept the default update channel to `nightly` so that the behavior of AstroNvim doesn't change (this could be considered a breaking change to some). We are planning to make the `stable` channel the default update channel when Neovim v0.8 is released and we tag AstroNvim v2.0.0 to incorporate this "breaking" change.
## 🌟 Preview
![Preview1](https://github.com/AstroNvim/astronvim.github.io/raw/main/static/img/dashboard.png)
@@ -48,7 +46,7 @@ AstroNvim is an aesthetic and feature-rich neovim config that is extensible and
## ⚡ Requirements
- [Nerd Fonts](https://www.nerdfonts.com/font-downloads)
- [Stable Neovim 0.7+](https://github.com/neovim/neovim/releases/tag/v0.7.0)
- [Neovim 0.8+ (*Not* including nightly)](https://github.com/neovim/neovim/releases/tag/v0.8.0)
- A clipboard tool is necessary for the integration with the system clipboard (see [`:help clipboard-tool`](https://neovim.io/doc/user/provider.html#clipboard-tool) for supported solutions)
- Terminal with true color support (for the default theme, otherwise it is dependent on the theme you are using)
- Optional Requirements:
@@ -61,8 +59,6 @@ AstroNvim is an aesthetic and feature-rich neovim config that is extensible and
> Note when using default theme: For MacOS, the default terminal does not have true color support. You will need to use [iTerm2](https://iterm2.com/) or another [terminal emulator](https://gist.github.com/XVilka/8346728#terminal-emulators) that has true color support.
> Note if you are still on Neovim v0.6: You can still install the previous version of AstroNvim that supported. After cloning the repository run `git checkout nvim-0.6` to check out this version. This will no longer be receiving updates.
## 🛠️ Installation
#### Make a backup of your current nvim folder
+10 -6
View File
@@ -26,6 +26,8 @@ local signs = {
for _, sign in ipairs(signs) do
sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
astronvim.lsp.formatting = astronvim.user_plugin_opts("lsp.formatting", { disabled = {} })
astronvim.lsp.diagnostics = {
off = {
underline = false,
@@ -67,12 +69,14 @@ end
-- @param client the client to check if formatting should be enabled
-- @return true if the client should be used for formatting
astronvim.lsp.format_filter = function(client)
local formatting = astronvim.user_plugin_opts("lsp.formatting", { disabled = {} })
if type(formatting.filter) == "function" then
return formatting.filter(client)
else
return not vim.tbl_contains(formatting.disabled, client.name)
end
local filter = astronvim.lsp.filter
local disabled = astronvim.lsp.disabled
-- if client is fully disabled, return false
if vim.tbl_contains(disabled, client.name) then return false end
-- if filter function is defined and client is filtered out, return false
if type(filter) == "function" and not filter(client) then return false end
-- client has passed all checks, enable it for formatting
return true
end
--- The `on_attach` function used by AstroNvim
+2 -15
View File
@@ -133,7 +133,7 @@ local config = {
},
formatting = {
disabled = { -- disable formatting capabilities for the listed clients
"sumneko_lua",
-- "sumneko_lua",
},
-- filter = function(client) -- fully override the default formatting function
-- return true
@@ -245,9 +245,6 @@ local config = {
["mason-tool-installer"] = { -- overrides `require("mason-tool-installer").setup(...)`
-- ensure_installed = { "prettier", "stylua" },
},
packer = { -- overrides `require("packer").setup(...)`
compile_path = vim.fn.stdpath "data" .. "/packer_compiled.lua",
},
},
-- LuaSnip Options
@@ -256,7 +253,7 @@ local config = {
vscode_snippet_paths = {},
-- Extend filetypes
filetype_extend = {
javascript = { "javascriptreact" },
-- javascript = { "javascriptreact" },
},
},
@@ -295,16 +292,6 @@ local config = {
-- augroups/autocommands and custom filetypes also this just pure lua so
-- anything that doesn't fit in the normal config locations above can go here
polish = function()
-- Set key binding
-- Set autocommands
-- vim.api.nvim_create_augroup("packer_conf", { clear = true })
-- vim.api.nvim_create_autocmd("BufWritePost", {
-- desc = "Sync packer after modifying plugins.lua",
-- group = "packer_conf",
-- pattern = "plugins.lua",
-- command = "source <afile> | PackerSync",
-- })
-- Set up custom filetypes
-- vim.filetype.add {
-- extension = {