Merge commit 'f4858d42a8' as 'config/nvim'

This commit is contained in:
neoteny 2021-11-28 22:27:34 +02:00
commit a6d1f45fd6
36 changed files with 906 additions and 0 deletions

View file

@ -0,0 +1,26 @@
return function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
local function buf_map(...)
vim.api.nvim_buf_set_keymap(bufnr, "n", ...)
end
local opts = { noremap = true, silent = true }
buf_map("K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
buf_map("gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
buf_map("gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
buf_map("gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
buf_map("gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
buf_map("gs", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
buf_map("gl", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
buf_map("<leader>la", "<cmd>Telescope lsp_code_actions<CR>", opts)
buf_map("<leader>lA", "lua vim.lsp.buf.range_code_action()<CR>", opts)
buf_map("<leader>ld", "<cmd>TroubleToggle<cr>", opts)
buf_map("<leader>lr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
buf_map("<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
buf_map("<leader>ls", "<cmd>Telescope lsp_document_symbols<CR>", opts)
buf_map("<leader>li", "<cmd>LspInfo<CR>", opts)
buf_map("<leader>lR", "<cmd>LspRestart<CR>", opts)
end

View file

@ -0,0 +1,22 @@
local on_attach = require "lsp.attach"
local M = {}
function M.setup()
require("nvim-lsp-installer").on_server_ready(function(server)
local opts = { on_attach = on_attach }
local ok, server_opts = pcall(require, "lsp.providers." .. server.name)
if ok then
opts = vim.tbl_deep_extend("force", opts, server_opts or {})
end
server:setup(opts)
vim.cmd [[ do User LspAttachBuffers ]]
require("lsp.null").setup()
require("lspconfig")["null-ls"].setup {}
end)
end
return M

View file

@ -0,0 +1,38 @@
local M = {}
function M.setup()
local null_ls = require "null-ls"
local fmt = null_ls.builtins.formatting
local lint = null_ls.builtins.diagnostics
null_ls.config {
sources = {
-- Lua
fmt.stylua,
lint.selene,
-- Golang
fmt.gofumpt,
fmt.goimports,
-- JavaScirpt
fmt.prettierd,
lint.eslint_d,
-- Shell
fmt.shfmt,
lint.shellcheck,
-- Python
fmt.black,
fmt.isort,
lint.flake8,
-- Rust
fmt.rustfmt,
},
}
end
return M

View file

@ -0,0 +1,16 @@
return {
settings = {
schemaDownload = {
enable = true,
},
schemas = {
{ fileMatch = { "package.json" }, url = "https://json.schemastore.org/package.json" },
{ url = "https://json.schemastore.org/tsconfig.json", fileMatch = { "tsconfig.json", "tsconfig.*.json" } },
{ url = "https://json.schemastore.org/lerna.json", fileMatch = { "lerna.json" } },
{ url = "https://json.schemastore.org/eslintrc.json", fileMatch = { ".eslintrc.json", ".eslintrc" } },
{ url = "https://json.schemastore.org/prettierrc", fileMatch = { ".prettierrc", ".prettierrc.json", "prettier.config.json" } },
{ fileMatch = { ".golangci.toml", ".golangci.json" }, url = "https://json.schemastore.org/golangci-lint.json" },
{ fileMatch = { "package.json" }, url = "https://json.schemastore.org/package.json" },
},
},
}

View file

@ -0,0 +1,8 @@
return {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = false,
},
},
}

View file

@ -0,0 +1,12 @@
return {
settings = {
sqls = {
connections = {
{
driver = "postgresql",
dataSourceName = "host=0.0.0.0 port=5432 user=postgres password=qwerty123 dbname=postgres sslmode=disable",
},
},
},
},
}

View file

@ -0,0 +1,15 @@
return {
settings = {
Lua = {
diagnostics = { globals = { "vim" } },
workspace = {
library = {
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
},
maxPreload = 100000,
preloadFileSize = 10000,
},
},
},
}

View file

@ -0,0 +1,19 @@
return {
setup = {
handlers = {
["textDocument/publishDiagnostics"] = function(_, _, p, id, _, cfg)
if p.diagnostics ~= nil then
local i = 1
while i <= #p.diagnostics do
if p.diagnostics[i].code == 80001 then
table.remove(p.diagnostics, i)
else
i = i + 1
end
end
end
vim.lsp.diagnostic.on_publish_diagnostics(_, _, p, id, _, cfg)
end,
},
},
}

View file

@ -0,0 +1,14 @@
return {
settings = {
yaml = {
hover = true,
completion = true,
validate = true,
schemaStore = {
enable = true,
url = "https://www.schemastore.org/api/json/catalog.json",
},
schemas = {},
},
},
}