How to use yaml formatter with Neovim builtin LSP client?
See original GitHub issueThe codebase contains a yamlFormatter although the server capabilities says otherwise:
documentFormattingProvider: false,
The formatter runs perfectly well in VSCode. I installed the server using npm
and running the server with the default settings.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Neovim for Beginners —LSP using null-ls.nvim | by alpha2phi
nvim to inject LSP diagnostics, code actions, and more by allowing third-party tools and utilities to hook into the LSP client. In this...
Read more >Neovim Spaghetti - LSP Servers, Linters, Formatters ... - roobert
LSP facilitates features like go-to-definition, find-references, hover, completion, rename, format, refactor, etc., using semantic ...
Read more >How to set up Neovim 0.5 + Modern plugins (LSP, Treesitter ...
I manage plugins in $HOME/.config/nvim/plug.vim . Then, relaunch Neovim and run :PlugInstall to install plugins. Set up the built-in ...
Read more >My Neovim setup for React, TypeScript, Tailwind CSS, etc
As you may know, I mainly use Neovim to code my app called Inkdrop, a. ... plugin for Neovim's built-in LSP client; williamboman/mason.nvim...
Read more >Null-ls - Linter & Formatter - Rocky Linux Documentation
The jose-elias-alvarez/null-ls.nvim plugin, although not essential to the ... you should use vim.lsp.buf.format({ bufnr = bufnr }) instead ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think you should directly use
prettier
for YAML files as the language server uses that internally.https://github.com/redhat-developer/yaml-language-server/blob/f03324a3a81c1a32b153b61dea685308865b5dac/src/languageservice/services/yamlFormatter.ts#L47
But, if you want to use the language server, then I suggest to guard the line so that it only affects the YAML language server:
Never mind. I got it working myself by adding a line to my
on_attach
function: