Skip to content

Commit 7e70651

Browse files
committed
silently format lua file using stylua
We need to disable the mapping set for LSP, otherwise the mapping set in lua.vim will be overridden.
1 parent 1d66475 commit 7e70651

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

after/ftplugin/lua.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set formatoptions-=r
44

55
nnoremap <buffer><silent> <F9> :luafile %<CR>
66
7-
nnoremap <buffer><silent> <space>f <cmd>!stylua %<CR>
7+
nnoremap <buffer><silent> <space>f <cmd>silent !stylua %<CR>

lua/config/lsp.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ local custom_attach = function(client, bufnr)
5050
end, { desc = "list workspace folder" })
5151

5252
-- Set some key bindings conditional on server capabilities
53-
if client.server_capabilities.documentFormattingProvider then
53+
if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then
5454
map({ "n", "x" }, "<space>f", vim.lsp.buf.format, { desc = "format code" })
5555
end
5656

0 commit comments

Comments
 (0)