update-2022-04-12

This commit is contained in:
Lee Tang
2022-04-12 23:03:05 +08:00
parent 0b56283159
commit 76e08244e7
17 changed files with 290 additions and 68 deletions

View File

@@ -0,0 +1,7 @@
require('indent_blankline').setup({
char = '|',
buftype_exclude = { 'terminal' },
show_trailing_blankline_indent = false,
-- show_current_context = true,
use_treesitter = true,
})

View File

@@ -1,12 +0,0 @@
local g = vim.g
local map = require('utils').map
map('n', '<leader>te', ':NERDTreeToggle<CR>')
vim.cmd([[
autocmd VimEnter * NERDTree | wincmd p
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
]])

View File

@@ -3,7 +3,28 @@ local api = vim.api
local cmd = vim.cmd
local lsp_installer = require('nvim-lsp-installer')
local lsp_installer_servers = require('nvim-lsp-installer.servers')
-- Include the servers you want to have installed by default below
local servers = {
'bashls',
'pylsp',
'yamlls',
'eslint',
'jsonls',
'sumneko_lua',
'rust_analyzer',
'clangd',
'gopls',
'tsserver',
'prosemd_lsp',
}
for _, name in pairs(servers) do
local server_is_found, server = lsp_installer.get_server(name)
if server_is_found and not server:is_installed() then
print('Installing ' .. name)
server:install()
end
end
-- lspconfig && lspinstaller
local on_attach = function(client, bufnr)
@@ -16,11 +37,10 @@ local on_attach = function(client, bufnr)
--require "lsp_signature".on_attach()
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
--buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap = true, silent = true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
@@ -43,6 +63,7 @@ local on_attach = function(client, bufnr)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
--buf_set_keymap('i', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.cmd([[
@@ -103,14 +124,28 @@ lsp_installer.on_server_ready(function(server)
local conf = require(string.format('config.lsp_servers.%s', server.name))
opts = vim.tbl_deep_extend('force', opts, conf)
end
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
if server.name == 'rust_analyzer' then
-- Initialize the LSP via rust-tools instead
require('rust-tools').setup({
-- The "server" property provided in rust-tools setup function are the
-- settings rust-tools will provide to lspconfig during init. --
-- We merge the necessary settings from nvim-lsp-installer (server:get_default_options())
-- with the user's own settings (opts).
server = vim.tbl_deep_extend('force', server:get_default_options(), opts),
})
server:attach_buffers()
-- Only if standalone support is needed
--require('rust-tools').start_standalone_if_required()
else
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end
end)
local null_ls = require('null-ls')

View File

@@ -0,0 +1,25 @@
local g = vim.g
local border_chars = {
TOP_LEFT = '',
TOP_RIGHT = '',
MID_HORIZONTAL = '',
MID_VERTICAL = '',
BOTTOM_LEFT = '',
BOTTOM_RIGHT = '',
}
g.lsp_utils_location_opts = {
mode = 'split',
preview = {
title = 'Location Preview',
border = true,
border_chars = border_chars,
},
keymaps = {
n = {
['<C-n>'] = 'j',
['<C-p>'] = 'k',
},
},
}

View File

@@ -56,7 +56,7 @@ require('nvim-tree').setup({
filters = {
custom = { '.git' }, -- ignore .git
},
auto_close = true,
--auto_close = true,
hijack_netrw = true,
update_cwd = true,
focus_tree = false,
@@ -66,6 +66,7 @@ require('nvim-tree').setup({
map('n', '<leader>te', ':NvimTreeToggle<CR>')
vim.cmd([[
autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif
augroup nvimtree
autocmd VimEnter * lua require('nvim-tree').toggle(false, true)
augroup END

View File

@@ -21,9 +21,8 @@ cmp.setup({
return vim_item
end,
},
mapping = {
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
--["<C-e>"] = cmp.mapping.close(),
@@ -34,7 +33,13 @@ cmp.setup({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
},
['<C-y>'] = cmp.mapping.confirm({ select = true }),
--},
}),
--mapping = {
----['<C-n>'] = cmp.mapping.select_next_item(),
----['<C-p>'] = cmp.mapping.select_prev_item(),
sources = {
{ name = 'nvim_lsp' },
{ name = 'buffer' },

View File

@@ -1,6 +1,6 @@
-- treesitter
require('nvim-treesitter.configs').setup({
ensure_installed = 'maintained', -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ensure_installed = 'all', -- one of "all", "maintained" (parsers with maintainers), or a list of languages
ignore_install = { 'javascript' }, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension