neovim: replace nvim-lint + neoformat with null-ls.nvim

Also update config for jsonls and yamlls.
This commit is contained in:
FollieHiyuki 2021-10-06 00:17:41 +07:00
parent 2248faa795
commit 4508f2a819
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
4 changed files with 97 additions and 44 deletions

View File

@ -1,4 +1,3 @@
-- TODO: add other highlight groups from nord.vim
local M = {}
M.colors = {

View File

@ -77,6 +77,11 @@ function M.lsp_conf()
on_attach = on_attach,
capabilities = capabilities,
filetypes = {'c', 'cpp'},
init_options = {
usePlaceholders = true,
completeUnimported = true,
clangdFileStatus = true
},
cmd = {
'clangd',
'-j=2',
@ -154,15 +159,23 @@ function M.lsp_conf()
}
-- Yaml
-- lspconf.yamlls.setup {
-- on_attach = on_attach,
-- capabilities = capabilities,
-- cmd = {servers_path .. '/yamlls/node_modules/.bin/yaml-language-server', '--stdio'},
-- settings = {
-- redhat = {telemetry = {enabled = false}},
-- yaml = {format = {bracketSpacing = true}}
-- }
-- }
lspconf.yamlls.setup {
on_attach = on_attach,
capabilities = capabilities,
cmd = {servers_path .. '/yamlls/node_modules/.bin/yaml-language-server', '--stdio'},
settings = {
redhat = {telemetry = {enabled = false}},
yaml = {
format = {
bracketSpacing = true,
printWidth = 80,
-- proseWrap = 'always', -- default is 'preserve'
-- singleQuote = true,
-- editor.formatOnType = true
}
}
}
}
-- Tailwind
-- lspconf.tailwindcss.setup {
@ -199,6 +212,56 @@ function M.lsp_conf()
filetypes = {'html', 'markdown'}
}
-- JSON
lspconf.jsonls.setup {
on_attach = on_attach,
capabilities = capabilities,
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-json-language-server', '--stdio'},
settings = {
json = {
-- Schema catalog: https://www.schemastore.org/api/json/catalog.json
schemas = {
{
fileMatch = {'package.json'},
url = 'https://json.schemastore.org/package.json'
}, {
fileMatch = {'tsconfig*.json'},
url = 'https://json.schemastore.org/tsconfig.json'
}, {
fileMatch = {
'.prettierrc', '.prettierrc.json',
'prettier.config.json'
},
url = 'https://json.schemastore.org/prettierrc.json'
}, {
fileMatch = {'.eslintrc', '.eslintrc.json'},
url = 'https://json.schemastore.org/eslintrc.json'
}, {
fileMatch = {
'.babelrc', '.babelrc.json', 'babel.config.json'
},
url = 'https://json.schemastore.org/babelrc.json'
},
{
fileMatch = {'lerna.json'},
url = 'https://json.schemastore.org/lerna.json'
}, {
fileMatch = {'now.json', 'vercel.json'},
url = 'https://json.schemastore.org/now.json'
}, {
fileMatch = {
'.stylelintrc', '.stylelintrc.json',
'stylelint.config.json'
},
url = 'http://json.schemastore.org/stylelintrc.json'
}
}
}
}
}
-- TODO: efm-langserver
-- Others
local servers = {
rust_analyzer = {'rust-analyzer'},
@ -206,7 +269,6 @@ function M.lsp_conf()
cmake = {servers_path .. '/cmake/venv/bin/cmake-language-server'},
bashls = {servers_path .. '/bashls/node_modules/.bin/bash-language-server', 'start'},
dockerls = {servers_path .. '/dockerls/node_modules/.bin/docker-langserver', '--stdio'},
jsonls = {servers_path .. '/vscode/node_modules/.bin/vscode-json-language-server', '--stdio'},
cssls = {servers_path .. '/vscode/node_modules/.bin/vscode-css-language-server', '--stdio'},
pyright = {servers_path .. '/pyright/node_modules/.bin/pyright-langserver', '--stdio'},
-- vimls = {servers_path .. '/vimls/node_modules/.bin/vim-language-server', '--stdio'},
@ -312,28 +374,7 @@ function M.outline_conf()
}
end
function M.lint_conf()
require('lint').linters_by_ft = {
markdown = {'vale', 'markdownlint', 'languagetool'},
tex = {'vale', 'languagetool'},
vim = {'vint'},
-- lua = {'luacheck'},
c = {'clangtidy', 'cppcheck'},
cpp = {'clangtidy', 'clazy', 'cppcheck'},
python = {'pylint', 'flake8', 'pycodestyle'},
go = {'revive', 'golangcilint'},
sh = {'shellcheck'},
bash = {'shellcheck'},
zsh = {'shellcheck'},
html = {'tidy', 'stylelint'},
css = {'stylelint'},
scss = {'stylelint'},
sass = {'stylelint'},
javascript = {'eslint', 'stylelint'}
}
-- TODO: custom cmds for linters installed with pip (using virtualenv)
-- vint, pylint, flake8, pycodestyle, codespell
vim.api.nvim_command [[ au BufRead,BufWritePost * lua require('lint').try_lint() ]]
function M.null_ls_conf()
end
function M.dap_conf()

View File

@ -60,7 +60,7 @@ return packer.startup(function(use)
}
use {
'RRethy/vim-illuminate',
event = {'BufReadPre', 'BufNewFile'}
event = 'CursorHold'
}
use {
'lukas-reineke/indent-blankline.nvim',
@ -174,10 +174,11 @@ return packer.startup(function(use)
cmd = {'SymbolsOutline', 'SymbolsOutlineOpen'},
setup = lsp.outline_conf
}
use { -- TODO: scripts to install/update linters
'mfussenegger/nvim-lint',
event = 'BufRead',
config = lsp.lint_conf
use { -- TODO: config, scripts to install formaters, linters
'jose-elias-alvarez/null-ls.nvim',
wants = 'plenary.nvim',
after = 'nvim-lspconfig',
config = lsp.null_ls_conf
}
use { -- TODO: config, scripts to install/update dap servers
'rcarriga/nvim-dap-ui',
@ -279,6 +280,10 @@ return packer.startup(function(use)
wants = {'diffview.nvim', 'plenary.nvim'},
requires = {{
'sindrets/diffview.nvim',
cmd = {
'DiffviewOpen','DiffviewClose',
'DiffviewToggleFiles', 'DiffviewFocusFiles'
},
config = tools.diffview_conf,
opt = true
}},
@ -363,7 +368,7 @@ return packer.startup(function(use)
}
use {
'michaelb/sniprun',
run = 'bash ./install.sh 1',
run = 'cargo build --release',
cmd = 'SnipRun',
config = tools.sniprun_conf
}
@ -371,13 +376,9 @@ return packer.startup(function(use)
'NTBBloodbath/rest.nvim',
keys = {'<Plug>RestNvim', '<Plug>RestNvimPreview', '<Plug>RestNvimLast'},
wants = {'plenary.nvim', 'nvim-treesitter'},
run = ':TSInstall http',
-- run = ':TSInstall http',
config = tools.rest_conf
}
use { -- TODO: move to formater.nvim
'sbdchd/neoformat',
cmd = 'Neoformat'
}
use {
'folke/persistence.nvim',
event = 'BufEnter',

View File

@ -0,0 +1,12 @@
#!/bin/sh -e
current_path="$PWD"
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/efm"
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
cd ${server_path}
GOPATH="${server_path}" GOBIN="${server_path}" go install github.com/mattn/efm-langserver@latest
GOPATH="${server_path}" GOBIN="${server_path}" go clean -modcache
cd ${current_path}