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

View File

@@ -15,13 +15,13 @@ end
return require('packer').startup(function(use)
use('wbthomason/packer.nvim')
use('folke/lua-dev.nvim')
use('nvim-lua/plenary.nvim')
use('folke/tokyonight.nvim')
use('kyazdani42/nvim-web-devicons')
use('tpope/vim-fugitive') -- git fugitive
use({
'lewis6991/gitsigns.nvim',
requires = { 'nvim-lua/plenary.nvim' },
config = function()
require('config.gitsigns')
end,
@@ -36,31 +36,24 @@ return require('packer').startup(function(use)
})
end,
})
use({
'folke/trouble.nvim',
config = function()
require('trouble').setup({})
end,
})
--use({
--'TimUntersberger/neogit',
--requires = 'nvim-lua/plenary.nvim',
--'folke/trouble.nvim',
--config = function()
--local neogit = require('neogit')
--neogit.setup({
--integrations = {
--diffview = true,
--},
--})
--require('trouble').setup({})
--end,
--})
--use({
--'sindrets/diffview.nvim',
--requires = 'nvim-lua/plenary.nvim',
--config = function()
--require('diffview').setup({})
--end,
--})
use({
'lukas-reineke/indent-blankline.nvim',
config = function()
require('config.indent-blankline')
end,
})
use({
'MattesGroeger/vim-bookmarks',
requires = 'tom-anders/telescope-vim-bookmarks.nvim',
@@ -72,13 +65,6 @@ return require('packer').startup(function(use)
use({
't9md/vim-choosewin',
})
-- use "easymotion/vim-easymotion"
--use {
--"voldikss/vim-floaterm",
--config = function()
--require "config.nvim_floaterm"
--end
--}
use({
'akinsho/toggleterm.nvim',
config = function()
@@ -101,21 +87,14 @@ return require('packer').startup(function(use)
end,
})
use({
'preservim/nerdtree',
'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons',
config = function()
require('config.nerdtree')
require('config.nvim-tree')
end,
})
--use({
--'kyazdani42/nvim-tree.lua',
--requires = 'kyazdani42/nvim-web-devicons',
--config = function()
--require('config.nvim-tree')
--end,
--})
use({
'nvim-telescope/telescope.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function()
require('config.nvim_telescope')
end,
@@ -133,6 +112,18 @@ return require('packer').startup(function(use)
})
use('hrsh7th/cmp-buffer')
use('hrsh7th/cmp-nvim-lsp')
use({
'folke/lsp-colors.nvim',
config = function()
require('lsp-colors').setup({})
end,
})
use({
'RishabhRD/nvim-lsputils',
config = function()
require('config.nvim-lsputils')
end,
})
use({
'github/copilot.vim',
setup = function() end,
@@ -140,7 +131,6 @@ return require('packer').startup(function(use)
require('config.copilot')
end,
})
--use('sbdchd/neoformat')
use({
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate',
@@ -153,7 +143,6 @@ return require('packer').startup(function(use)
run = 'cd app && yarn install',
cmd = { 'MarkdownPreview', 'MarkdownPreviewStop' },
})
--use {"glepnir/spaceline.vim", requires = "kyazdani42/nvim-web-devicons"}
use({
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
@@ -174,7 +163,6 @@ return require('packer').startup(function(use)
})
use({
'folke/todo-comments.nvim',
requires = 'nvim-lua/plenary.nvim',
config = function()
require('todo-comments').setup({})
end,
@@ -220,9 +208,13 @@ return require('packer').startup(function(use)
use({
'williamboman/nvim-lsp-installer',
config = function()
require('config.lspconfig')
require('config.nvim-lsp-installer')
end,
})
-- k8s
use('andrewstuart/vim-kubernetes')
-- go
use({
'fatih/vim-go',
run = ':GoUpdateBinaries',
@@ -241,7 +233,8 @@ return require('packer').startup(function(use)
use('Vimjas/vim-python-pep8-indent')
-- rust
use('rust-lang/rust.vim')
use('andrewstuart/vim-kubernetes')
use('simrat39/rust-tools.nvim')
use('mfussenegger/nvim-dap')
end)
-- require("todo-comments").setup {}