Skip to content
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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()

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"

Copy link
Author

Choose a reason for hiding this comment

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

Good point :). Updated 馃憤馃徏

vim.lsp.buf.format { async = true }
end, '[F]ormat code')

-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
Expand Down
Loading