first commit
This commit is contained in:
54
lua/custom/configs/lspconfig.lua
Normal file
54
lua/custom/configs/lspconfig.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
local on_attach = require("plugins.configs.lspconfig").on_attach
|
||||
local capabilities = require("plugins.configs.lspconfig").capabilities
|
||||
|
||||
local lspconfig = require "lspconfig"
|
||||
local util = require "lspconfig/util"
|
||||
|
||||
-- LUA LSP
|
||||
local runtime_path = vim.split(package.path, ";")
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
lspconfig.lua_ls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = "LuaJIT",
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- GO LSP
|
||||
lspconfig.gopls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = { "gopls" },
|
||||
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
||||
root_dir = util.root_pattern("go.work", "go.mod", ".git"),
|
||||
settings = {
|
||||
gopls = {
|
||||
completeUnimported = true,
|
||||
usePlaceholders = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
38
lua/custom/configs/null-ls.lua
Normal file
38
lua/custom/configs/null-ls.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
local null_ls = require "null-ls"
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
local sources = {
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.formatting.goimports_reviser,
|
||||
null_ls.builtins.formatting.gofumpt,
|
||||
null_ls.builtins.formatting.golines.with {
|
||||
extra_args = {
|
||||
"--max-len=180",
|
||||
"--base-formatter=gofumpt",
|
||||
},
|
||||
},
|
||||
null_ls.builtins.formatting.eslint_d,
|
||||
null_ls.builtins.formatting.yamlfmt,
|
||||
null_ls.builtins.formatting.protolint,
|
||||
-- 诊断
|
||||
null_ls.builtins.diagnostics.protolint,
|
||||
null_ls.builtins.diagnostics.eslint_d,
|
||||
null_ls.builtins.code_actions.eslint_d,
|
||||
}
|
||||
|
||||
null_ls.setup {
|
||||
debounce = 1000,
|
||||
default_timeout = 5000,
|
||||
sources = sources,
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method "textDocument/formatting" then
|
||||
vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr }
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format { bufnr = bufnr }
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
14
lua/custom/configs/others.lua
Normal file
14
lua/custom/configs/others.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
local M = {}
|
||||
M.indent_blackline = {
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
show_end_of_line = true,
|
||||
space_char_blankline = " ",
|
||||
}
|
||||
M.nvimtree = {
|
||||
filters = {
|
||||
dotfiles = true,
|
||||
exclude = { ".golangci*", ".protolint*", ".gitignore", ".eslintrc*" },
|
||||
},
|
||||
}
|
||||
return M
|
||||
61
lua/custom/configs/treesitter.lua
Normal file
61
lua/custom/configs/treesitter.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
return {
|
||||
-- A list of parser names, or "all" (the four listed parsers should always be installed)
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"css",
|
||||
"dart",
|
||||
"diff",
|
||||
"dockerfile",
|
||||
"git_rebase",
|
||||
"gitattributes",
|
||||
"gitcommit",
|
||||
"gitignore",
|
||||
"go",
|
||||
"gomod",
|
||||
"gosum",
|
||||
"gowork",
|
||||
"html",
|
||||
"java",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"rust",
|
||||
"toml",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vue",
|
||||
"yaml",
|
||||
"proto",
|
||||
},
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = true,
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
|
||||
auto_install = true,
|
||||
-- List of parsers to ignore installing (for "all")
|
||||
ignore_install = {},
|
||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<CR>",
|
||||
node_incremental = "<CR>",
|
||||
node_decremental = "<BS>",
|
||||
scope_incremental = "<TAB>",
|
||||
},
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user