diff options
author | kylo252 <[email protected]> | 2022-07-31 14:27:59 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-07-31 14:27:59 +0200 |
commit | dec21bbab6cf9102e236806e20273d08f32f8716 (patch) | |
tree | 84ce943bb53f9f4ec8bae9932cbbafe2152ea77a /lua/lvim/lsp/utils.lua | |
parent | 6ab3e8a73920e3d2e02e57f7dd3a1f3d8e54ee63 (diff) |
feat(lsp): bind formatexpr and omnifunc by default (#2865)
Diffstat (limited to 'lua/lvim/lsp/utils.lua')
-rw-r--r-- | lua/lvim/lsp/utils.lua | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua index 2a23e501..fa1ac6d9 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -132,18 +132,20 @@ end ---filter passed to vim.lsp.buf.format ---always selects null-ls if it's available and caches the value per buffer ---@param client table client attached to a buffer ----@return table chosen clients +---@return boolean if client matches function M.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 avalable_sources = s.get_available(filetype, method) + local avalable_formatters = s.get_available(filetype, method) - if #avalable_sources > 0 then + if #avalable_formatters > 0 then return client.name == "null-ls" - else + elseif client.supports_method "textDocument/formatting" then return true + else + return false end end @@ -159,6 +161,7 @@ function M.format(opts) local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() + ---@type table|nil local clients = vim.lsp.get_active_clients { id = opts.id, bufnr = bufnr, |