Add null-ls

This commit is contained in:
Zoe Roux
2022-05-22 16:21:56 +02:00
parent d5866d6fde
commit 0f03582c90
6 changed files with 94 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ M.setup = function()
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
@@ -25,7 +25,7 @@ M.setup = function()
end
local function lsp_highlight_document(client)
if client.resolved_capabilities.document_highlight then
if client.server_capabilities.documentHighlightProvider then
vim.cmd [[
augroup lsp_document_highlight
autocmd! * <buffer>
@@ -48,6 +48,15 @@ wk.register({
},
})
function _LSP_FORMAT_FILTER(clients)
for _, v in ipairs(clients) do
if v.name == "null-ls" and v.server_capabilities.documentFormattingProvider then
return { v }
end
end
return clients
end
local lsp_keymaps = function(bufnr)
wk.register({
g = {
@@ -64,7 +73,7 @@ local lsp_keymaps = function(bufnr)
r = { '<cmd>lua vim.lsp.buf.rename()<CR>', "Rename" },
a = { '<cmd>lua vim.lsp.buf.code_action()<CR>', "Code action" },
l = { '<cmd>lua vim.lsp.codelens.run()<CR>', "Run code lens" },
f = { '<cmd>lua vim.lsp.buf.formatting()<CR>', "Format" },
f = { '<cmd>lua vim.lsp.buf.format({filter=_LSP_FORMAT_FILTER})<CR>', "Format" },
g = { '<cmd>Telescope lsp_document_symbols<CR>', "Go to symbol" },
}
}, {

View File

@@ -3,4 +3,5 @@ require("lsp.handlers").setup()
require "lsp.cmp"
require "lsp.signature"
require "lsp.metals"
require "lsp.null-ls"

View File

@@ -0,0 +1,51 @@
local ok, nl = pcall(require, "null-ls")
if not ok then
return
end
local sources = {
nl.builtins.code_actions.eslint,
nl.builtins.diagnostics.eslint,
nl.builtins.formatting.eslint,
nl.builtins.formatting.prettier,
}
nl.setup({
sources = vim.tbl_map(function(source)
return source.with({
diagnostics_postprocess = function(diagnostic)
diagnostic.severity = vim.diagnostic.severity.HINT
end,
})
end, sources),
})
local function sort_ca_results(lsp_results)
local results = {}
local null_results = {}
for client_id, result in ipairs(lsp_results) do
local client = vim.lsp.get_client_by_id(client_id)
if client.name == "null-ls" then
table.insert(null_results, result)
else
table.insert(results, result)
end
end
-- Sort null-ls actions to the end
return vim.list_extend(results, null_results)
end
local buf_request_all = vim.lsp.buf_request_all
local ca
ca = function(bufnr, method, params, callback)
return buf_request_all(bufnr, method, params, function(lsp_results)
vim.lsp.buf_request_all = buf_request_all
local results = sort_ca_results(lsp_results)
local res = callback(results)
vim.lsp.buf_request_all = ca
return res
end)
end
vim.lsp.buf_request_all = ca

View File

@@ -52,10 +52,11 @@ return packer.startup(function(use)
use { "airblade/vim-rooter", config = function() vim.g.rooter_manual_only = 1 end }
use { "Pocco81/AutoSave.nvim", config = function() require "autosave".setup() end }
use { "AckslD/nvim-gfold.lua" }
use "AnonymusRaccoon/nvim-gfold.lua"
-- use { "AckslD/nvim-gfold.lua" }
use { "lewis6991/spellsitter.nvim" }
use {'psliwka/vim-dirtytalk', run = ':DirtytalkUpdate'}
use { 'psliwka/vim-dirtytalk', run = ':DirtytalkUpdate' }
use "ggandor/lightspeed.nvim"
@@ -90,6 +91,7 @@ return packer.startup(function(use)
use "Hoffs/omnisharp-extended-lsp.nvim"
use({ 'scalameta/nvim-metals', requires = { "nvim-lua/plenary.nvim" } })
use "b0o/schemastore.nvim"
use "jose-elias-alvarez/null-ls.nvim"
use {
"hrsh7th/cmp-nvim-lsp",
@@ -136,6 +138,12 @@ return packer.startup(function(use)
use "tpope/vim-fugitive"
use { "lewis6991/gitsigns.nvim", requires = { 'nvim-lua/plenary.nvim' } }
use({
"iamcco/markdown-preview.nvim",
run = "cd app && npm install",
setup = function() vim.g.mkdp_filetypes = { "markdown" } end,
ft = { "markdown" },
})
if PACKER_BOOTSTRAP then
require("packer").sync()

View File

@@ -8,7 +8,12 @@ vim.g["codi#virtual_text_pos"] = 90
local wk = require "which-key"
wk.register({
s = { "<cmd>CodiSelect<cr>", "Open a Sratchpad" },
s = {
name = "Scratchpads",
n = { "<cmd>CodiSelect<cr>", "Open a Sratchpad" },
e = { "<cmd>CodiExpand<cr>", "Expand the scratchad output" },
t = { "<cmd>Codi!!<cr>", "Toggle the scratchpad output" },
}
}, {
prefix = "<leader>",
})

View File

@@ -1,7 +1,20 @@
vim.opt.spell = true
-- vim.opt.spell = true
vim.opt.spelllang = { "en", "programming" }
local ok, spellsitter = pcall(require, 'spellsitter')
if ok then
spellsitter.setup()
end
function MARKDOWN_PREVIEW()
local wk = require "which-key"
wk.register({
mp = { "<cmd>MarkdownPreviewToggle<CR>", "Markdown preview" },
}, {
prefix = "<leader>",
buffer = 0,
})
end
vim.cmd("au FileType markdown lua MARKDOWN_PREVIEW()")