mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-24 09:48:51 +02:00
Add files via upload
This commit is contained in:
commit
e53a643e3d
54 changed files with 5285 additions and 0 deletions
22
lua/user/format_onsave.lua
Normal file
22
lua/user/format_onsave.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
function format_filter(client)
|
||||
local filetype = vim.bo.filetype
|
||||
local n = require "null-ls"
|
||||
local s = require "null-ls.sources"
|
||||
local method = n.methods.FORMATTING
|
||||
local available_formatters = s.get_available(filetype, method)
|
||||
|
||||
if #available_formatters > 0 then
|
||||
return client.name == "null-ls"
|
||||
elseif client.supports_method "textDocument/formatting" then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
vim.cmd [[
|
||||
augroup _lsp
|
||||
autocmd!
|
||||
" autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms =200, filter=format_filter}
|
||||
autocmd BufWritePre * lua vim.lsp.buf.format{filter=format_filter}
|
||||
augroup end
|
||||
]]
|
Loading…
Add table
Add a link
Reference in a new issue