mirror of
https://github.com/olexsmir/dotfiles.git
synced 2026-01-15 16:51:34 +02:00
Squashed 'config/nvim/' content from commit 0bd687c
git-subtree-dir: config/nvim git-subtree-split: 0bd687c8b69605fa1c7c88222354158b1c2de2f8
This commit is contained in:
commit
f4858d42a8
36 changed files with 906 additions and 0 deletions
26
lua/lsp/attach.lua
Normal file
26
lua/lsp/attach.lua
Normal 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
|
||||
22
lua/lsp/init.lua
Normal file
22
lua/lsp/init.lua
Normal 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
|
||||
38
lua/lsp/null.lua
Normal file
38
lua/lsp/null.lua
Normal 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
|
||||
16
lua/lsp/providers/jsonls.lua
Normal file
16
lua/lsp/providers/jsonls.lua
Normal 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" },
|
||||
},
|
||||
},
|
||||
}
|
||||
8
lua/lsp/providers/pyright.lua
Normal file
8
lua/lsp/providers/pyright.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
return {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
12
lua/lsp/providers/sqls.lua
Normal file
12
lua/lsp/providers/sqls.lua
Normal 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",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
15
lua/lsp/providers/sumneko_lua.lua
Normal file
15
lua/lsp/providers/sumneko_lua.lua
Normal 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
19
lua/lsp/providers/tsserver.lua
Normal file
19
lua/lsp/providers/tsserver.lua
Normal 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,
|
||||
},
|
||||
},
|
||||
}
|
||||
14
lua/lsp/providers/yamlls.lua
Normal file
14
lua/lsp/providers/yamlls.lua
Normal 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 = {},
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue