Skip to content

Conversation

@PolyMeilex
Copy link
Contributor

closes #936

For now I did not get around to porting the VsCode extension to LSP, so the easiest way to try this out is to use nvim:

cargo install --git https://github.com/PolyMeilex/StyLua.git --branch lsp
vim.lsp.config["stylua-lsp"] = {
  cmd = { "stylua", "--lsp" },
  filetypes = { "lua" },
}
vim.lsp.enable("stylua-lsp")

@PolyMeilex PolyMeilex force-pushed the lsp branch 2 times, most recently from 11e7d84 to 2af292d Compare April 17, 2025 18:51
@JohnnyMorganz
Copy link
Owner

Thanks for this, the implementation seems pretty reasonable to me!

I still need to give this a bit of a think though about whether I want to "bloat" stylua with this (tbh, i don't think it is much bloat). But it does seem like a nice feature to have, and would allow pretty easy set up with any IDE

Copy link
Owner

@JohnnyMorganz JohnnyMorganz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this implementation, going to move ahead with this

I restructured it slightly and added support for range formatting. I've also set up some integration tests.

Ideally we use output_diff to compute smaller text edits, but I'll leave that for later

@PolyMeilex
Copy link
Contributor Author

Lovely, I have been using this daily for the last 5 months without any issues so I'm happy to see it land 🚀 ❤️

@JohnnyMorganz JohnnyMorganz enabled auto-merge (squash) September 14, 2025 16:04
@JohnnyMorganz JohnnyMorganz merged commit 320739f into JohnnyMorganz:main Sep 14, 2025
21 checks passed
@PolyMeilex PolyMeilex deleted the lsp branch September 14, 2025 16:12
lan1812783 added a commit to lan1812783/nvim that referenced this pull request Oct 19, 2025
- LSP:
  - Use `after/lsp/` directory to configure LSP behavior
    (https://neovim.io/doc/user/lsp.html#lsp-faq) instead of manually
    call `vim.lsp.enable()` on each LSP configuration
  - Remap `grr` to not include declaration
  - Add format on save autocmd if the LSP server supports it
  - Remove the usage of the deprecated `vim.lsp.protocol.Methods`
    (neovim/neovim#35998) in favor of using their string literal
    counterparts
  - Use `stylua` via LSP mode (since v2.2.0) instead of via none-ls as
    the formatter
    - JohnnyMorganz/StyLua#970
    - neovim/nvim-lspconfig#4073
    - mason-org/mason-registry#11613
  - Add `fidget.nvim` plugin to visually see LSP progress messages
  - Add `buf-ls` LSP server to support Protocol Buffers development
- Add `winborder` option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Make available as LSP

2 participants