149 lines
4.0 KiB
Lua
149 lines
4.0 KiB
Lua
require('nvim-tree').setup({
|
|
sync_root_with_cwd = true,
|
|
respect_buf_cwd = true,
|
|
update_focused_file = {
|
|
enable = true,
|
|
update_root = true
|
|
},
|
|
})
|
|
|
|
require('nvim-treesitter.configs').setup({
|
|
highlight = {
|
|
enable = true,
|
|
additional_vim_regex_highlighting = false,
|
|
},
|
|
indent = {
|
|
enable = true,
|
|
},
|
|
})
|
|
|
|
-- :h mason-default-settings
|
|
require("mason").setup({
|
|
ui = {
|
|
icons = {
|
|
package_installed = "✓",
|
|
package_pending = "➜",
|
|
package_uninstalled = "✗",
|
|
},
|
|
},
|
|
mason = true
|
|
})
|
|
|
|
-- mason-lspconfig uses the `lspconfig` server names in the APIs it exposes - not `mason.nvim` package names
|
|
-- https://github.com/williamboman/mason-lspconfig.nvim/blob/main/doc/server-mapping.md
|
|
require("mason-lspconfig").setup({
|
|
-- 确保安装,根据需要填写
|
|
ensure_installed = {
|
|
"sumneko_lua",
|
|
"bashls",
|
|
"cssls",
|
|
"dockerls",
|
|
"emmet_ls",
|
|
"html",
|
|
"jsonls",
|
|
"rust_analyzer",
|
|
"yamlls",
|
|
"gopls"
|
|
},
|
|
})
|
|
|
|
require('navigator').setup()
|
|
vim.notify = require("notify")
|
|
require('symbols-outline').setup()
|
|
require('feline').setup()
|
|
require('bufferline').setup()
|
|
|
|
require('impatient')
|
|
require('gitsigns').setup()
|
|
require('telescope').load_extension('projects')
|
|
require("nvim-dap-virtual-text").setup()
|
|
|
|
vim.o.background = "dark" -- or "light" for light mode
|
|
vim.cmd([[colorscheme gruvbox]])
|
|
|
|
require("toggleterm").setup({
|
|
open_mapping = [[<c-\>]],
|
|
start_in_insert = true,
|
|
direction = 'horizontal'
|
|
})
|
|
|
|
require('go').setup()
|
|
|
|
local has_words_before = function()
|
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
end
|
|
local feedkey = function(key, mode)
|
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
end
|
|
local cmp = require('cmp')
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif vim.fn["vsnip#available"](1) == 1 then
|
|
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
|
elseif has_words_before() then
|
|
cmp.complete()
|
|
else
|
|
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
|
end
|
|
end, { "i", "s" }),
|
|
["<S-Tab>"] = cmp.mapping(function()
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
|
feedkey("<Plug>(vsnip-jump-prev)", "")
|
|
end
|
|
end, { "i", "s" }),
|
|
},
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'vsnip' }, -- For vsnip users.
|
|
}, {
|
|
{ name = 'buffer' },
|
|
})
|
|
})
|
|
|
|
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities() --nvim-cmp
|
|
|
|
local on_attach = function(client, bufnr)
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
|
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
end
|
|
|
|
-- Setup lspconfig.
|
|
local nvim_lsp = require('lspconfig')
|
|
|
|
-- setup languages
|
|
-- GoLang
|
|
nvim_lsp['gopls'].setup {
|
|
cmd = { 'gopls' },
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
gopls = {
|
|
experimentalPostfixCompletions = true,
|
|
analyses = {
|
|
unusedparams = true,
|
|
shadow = true,
|
|
},
|
|
staticcheck = true,
|
|
},
|
|
},
|
|
init_options = {
|
|
usePlaceholders = true,
|
|
}
|
|
}
|