mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-27 19:28:52 +02:00
fix : #8 warning [LSP][null-ls] timeout
This commit is contained in:
parent
55432b7b13
commit
520ae101c6
1 changed files with 20 additions and 20 deletions
|
@ -1,38 +1,38 @@
|
||||||
local run = 0
|
local run = 0
|
||||||
local frmt = vim.g.pcode_format_on_save or 0
|
local frmt = vim.g.pcode_format_on_save or 0
|
||||||
if frmt == 1 then
|
if frmt == 1 then
|
||||||
run = 1
|
run = 1
|
||||||
else
|
else
|
||||||
run = 0
|
run = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local buf_clients = vim.lsp.get_clients()
|
local buf_clients = vim.lsp.get_clients()
|
||||||
if next(buf_clients) == nil then
|
if next(buf_clients) == nil then
|
||||||
run = 0
|
run = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if run == 1 then
|
if run == 1 then
|
||||||
function FORMAT_FILTER(client)
|
function FORMAT_FILTER(client)
|
||||||
local filetype = vim.bo.filetype
|
local filetype = vim.bo.filetype
|
||||||
local n = require("null-ls")
|
local n = require "null-ls"
|
||||||
local s = require("null-ls.sources")
|
local s = require "null-ls.sources"
|
||||||
local method = n.methods.FORMATTING
|
local method = n.methods.FORMATTING
|
||||||
local available_formatters = s.get_available(filetype, method)
|
local available_formatters = s.get_available(filetype, method)
|
||||||
|
|
||||||
if #available_formatters > 0 then
|
if #available_formatters > 0 then
|
||||||
return client.name == "null-ls"
|
return client.name == "null-ls"
|
||||||
elseif client.supports_method("textDocument/formatting") then
|
elseif client.supports_method "textDocument/formatting" then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.cmd([[
|
vim.cmd [[
|
||||||
augroup _lsp
|
augroup _lsp
|
||||||
autocmd!
|
autocmd!
|
||||||
" autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms =200, filter=format_filter}
|
" autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms =200, filter=format_filter}
|
||||||
autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms=2000 ,filter=FORMAT_FILTER}
|
autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms=5000 ,filter=FORMAT_FILTER}
|
||||||
augroup end
|
augroup end
|
||||||
]])
|
]]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue