-
Notifications
You must be signed in to change notification settings - Fork 17.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LSP keymap to format current buffer #814
Conversation
What do folks think? I might find this useful. |
To add some more context, I'm coming from a setup of vim + coc.nvim, whose default example configuration exposes a "Format" command for doing this, and was trying to find if I could do the same thing after setting kickstart up |
init.lua
Outdated
@@ -501,6 +501,11 @@ require('lazy').setup({ | |||
-- For example, in C this would take you to the header. | |||
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') | |||
|
|||
-- Formats the current buffer | |||
map('<space>f', function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be <leader>
instead of <space>
? It might be the same at the moment, but if someone changes leader it might be confusing as to why formatting "stopped working"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point :). Updated 馃憤馃徏
In my view it would be better to use |
Well here is the alternative using conform: Kickstart is already using conform for formatting and in lua case the stylua formatting differs from LSP formatter. So using this will be more consistent. |
Closing in favor of #817 @GCrispino thanks for the suggestion. I hope you don't mind that we went with @dam9000 's implementation. We introduced conform in the rewrite for exactly this kind of thing :) |
@feoh no problem. Thanks all for considering this :) |
Having a key map to format the current buffer seems like something that is useful and general enough to have in the kickstart config, so I'm proposing this addition here
Feel free to close if you think that this is not true, though 馃檹馃徏