Installing New Language Servers (LSPs) with Mason
Better Vim provides seamless integration with various Language Servers (LSPs) through the use of Mason. Mason simplifies the setup and configuration of LSPs within Better Vim, allowing you to enhance your coding experience with specific language features and intelligent code suggestions. To install a new LSP using Mason, follow these steps:- Open the
better-vim.luafile located in your Better Vim configuration directory. - Locate the
lspsentry within the configuration file. If it doesn’t exist, you can create it as an empty table using the following format:
better-vim.lua
- Inside the
lspstable, add a new entry for the desired language server. The key should be a unique identifier for the LSP, and the value should be an empty table. This table is used to configure the specificsettings,init_options,cmdandon_attachfunction for the LSP through lspconfig. For example, to install theprismalslanguage server, your configuration would look like this:
better-vim.lua
You can find all available LSPs using the command
:Mason and doing a Ctrl + F
to find the language server you want to install.- Customize the configuration settings for the LSP within its respective table. You can refer to the documentation of the specific LSP or lspconfig for the available options and their meanings.
settings, init_options, cmd or customize the on_attach function,
see the example below:
better-vim.lua
-
Save the
better-vim.luafile. - Restart Better Vim or reload the configuration to apply the changes.
Installing New Formatters with none-ls
none-ls is a plugin integrated with Better Vim that enables you to format your code using various formatters. By leveraging none-ls, you can maintain consistent code formatting and adhere to coding style guidelines across different programming languages. To install a new formatter using none-ls, follow these steps:-
Open the
better-vim.luafile located in your Better Vim configuration directory. -
Locate the
formattersentry within the configuration file. If it doesn’t exist, you can create it as an empty table using the following format:
better-vim.lua
- Inside the
formatterstable, add a new entry for the desired formatter. The key should be a unique identifier for the formatter, and the value should be an empty table. This table is passed to thewithmethod when configuring formatting sources for none-ls. For example, to install theblade_formatterformatter, your configuration would look like this:
better-vim.lua
You can find all formatters for none-ls following this page
on the documetation. Just put the name of the formatter, you don’t need the part
null_ls.builtins.formatting- Customize the configuration settings for the formatter within its respective table. The available options and their meanings may vary depending on the formatter you are using. Refer to the documentation of the specific formatter for more information on the available options.
-
Save the
better-vim.luafile. - Restart Better Vim or reload the configuration to apply the changes.