mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-21 17:59:48 +01:00
Merge pull request #82 from n3oney/feature/null-priority
feat: give null-ls priority over other formatters
This commit is contained in:
commit
0afa7184f1
2 changed files with 37 additions and 3 deletions
|
@ -20,6 +20,12 @@ https://github.com/n3oney[n3oney]:
|
||||||
|
|
||||||
* Refactored the resolveDag function - you can just provide a string now, which will default to dag.entryAnywhere
|
* Refactored the resolveDag function - you can just provide a string now, which will default to dag.entryAnywhere
|
||||||
|
|
||||||
|
* Fixed formatting sometimes removing parts of files
|
||||||
|
|
||||||
|
* Made formatting synchronous
|
||||||
|
|
||||||
|
* Gave null-ls priority over other formatters
|
||||||
|
|
||||||
https://github.com/horriblename[horriblename]:
|
https://github.com/horriblename[horriblename]:
|
||||||
|
|
||||||
* Added `clangd` as alternative lsp for C/++.
|
* Added `clangd` as alternative lsp for C/++.
|
||||||
|
|
|
@ -39,15 +39,43 @@ in {
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
|
|
||||||
format_callback = function(client, bufnr)
|
format_callback = function(client, bufnr)
|
||||||
if vim.g.formatsave and client.supports_method("textDocument/formatting") then
|
if vim.g.formatsave then
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = augroup,
|
group = augroup,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
|
${
|
||||||
|
if config.vim.lsp.null-ls.enable
|
||||||
|
then ''
|
||||||
|
local function is_null_ls_formatting_enabled(bufnr)
|
||||||
|
local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
||||||
|
local generators = require("null-ls.generators").get_available(
|
||||||
|
file_type,
|
||||||
|
require("null-ls.methods").internal.FORMATTING
|
||||||
|
)
|
||||||
|
return #generators > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if is_null_ls_formatting_enabled(bufnr) then
|
||||||
vim.lsp.buf.format({
|
vim.lsp.buf.format({
|
||||||
bufnr = bufnr
|
bufnr = bufnr,
|
||||||
|
filter = function(client)
|
||||||
|
return client.name == "null-ls"
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
bufnr = bufnr,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
''
|
||||||
|
else "
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
bufnr = bufnr,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
}
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue