update
This commit is contained in:
parent
6df91b3fa5
commit
ac027655e9
@ -6,6 +6,7 @@ local tree_cb = require 'nvim-tree.config'.nvim_tree_callback -- following optio
|
||||
-- a add file/dir
|
||||
require 'nvim-tree'.setup {
|
||||
open_on_setup = true;
|
||||
open_on_setup_file = false,
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = true,
|
||||
@ -21,6 +22,7 @@ require 'nvim-tree'.setup {
|
||||
args = {},
|
||||
},
|
||||
view = {
|
||||
width = 24,
|
||||
mappings = {
|
||||
custom_only = true,
|
||||
list = {
|
||||
@ -68,7 +70,7 @@ vim.cmd([[colorscheme gruvbox]])
|
||||
vim.opt.termguicolors = true
|
||||
require("bufferline").setup {
|
||||
options = {
|
||||
sort_by = 'insert_after_current',
|
||||
sort_by = 'id',
|
||||
numbers = 'ordinal',
|
||||
-- 左侧让出 nvim-tree 的位置
|
||||
diagnostics = "nvim_lsp";
|
||||
|
||||
@ -1,27 +1,2 @@
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
return {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
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),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
13
lua/lsp/eslint.lua
Normal file
13
lua/lsp/eslint.lua
Normal file
@ -0,0 +1,13 @@
|
||||
local eslint_config = require("lspconfig.server_configurations.eslint")
|
||||
|
||||
return {
|
||||
on_attach = function(client, bufnr)
|
||||
-- neovim's LSP client does not currently support dynamic capabilities registration, so we need to set
|
||||
-- the resolved capabilities of the eslint server ourselves!
|
||||
client.resolved_capabilities.document_formatting = true
|
||||
end,
|
||||
settings = {
|
||||
format = { enable = true },
|
||||
},
|
||||
cmd = { "yarn", "exec", unpack(eslint_config.default_config.cmd) }
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
return {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
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),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -6,33 +6,10 @@ local lsp_installer = require "nvim-lsp-installer"
|
||||
-- Mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local keyOpts = { noremap = true, silent = true }
|
||||
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', keyOpts)
|
||||
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', keyOpts)
|
||||
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', keyOpts)
|
||||
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', keyOpts)
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-]>', '<cmd>lua vim.lsp.buf.definition()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', keyOpts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', keyOpts)
|
||||
end
|
||||
-- vim.api.nvim_buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
vim.api.nvim_set_keymap('n', '<C-]>', '<cmd>lua vim.lsp.buf.definition()<CR>', keyOpts)
|
||||
vim.api.nvim_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', keyOpts)
|
||||
vim.api.nvim_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', keyOpts)
|
||||
|
||||
|
||||
|
||||
@ -40,9 +17,17 @@ end
|
||||
-- https://github.com/williamboman/nvim-lsp-installer#available-lsps
|
||||
-- { key: 语言 value: 配置文件 }
|
||||
local servers = {
|
||||
sumneko_lua = require "lsp.base", -- /lua/lsp/lua.lua
|
||||
sumneko_lua = require "lsp.lua", -- /lua/lsp/lua.lua
|
||||
gopls = require "lsp.base",
|
||||
volar = require "lsp.base"
|
||||
volar = require "lsp.base",
|
||||
basels = require "lsp.base",
|
||||
cssls = require "lsp.base",
|
||||
eslint = require "lsp.eslint",
|
||||
tsserver = require "lsp.base",
|
||||
prosemd_lsp = require "lsp.base",
|
||||
pyright = require "lsp.base",
|
||||
rust_analyzer = require "lsp.base",
|
||||
tailwindcss = require "lsp.base",
|
||||
}
|
||||
|
||||
-- 自动安装 LanguageServers
|
||||
@ -58,7 +43,6 @@ end
|
||||
|
||||
lsp_installer.on_server_ready(function(server)
|
||||
local opts = servers[server.name]
|
||||
opts.on_attach = on_attach
|
||||
opts.capabilities = capabilities
|
||||
opts.flags = {
|
||||
debounce_text_changes = 150,
|
||||
@ -74,7 +58,7 @@ require('nvim-ts-autotag').setup()
|
||||
|
||||
-- nvim-cmp setup
|
||||
local cmp = require 'cmp'
|
||||
cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
|
||||
@ -12,6 +12,7 @@ return require('packer').startup(function()
|
||||
use { 'neovim/nvim-lspconfig', 'williamboman/nvim-lsp-installer' }
|
||||
|
||||
use 'windwp/nvim-autopairs'
|
||||
|
||||
use 'windwp/nvim-ts-autotag'
|
||||
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
|
||||
4
maps.vim
4
maps.vim
@ -37,8 +37,8 @@ nnoremap H ^
|
||||
" nmap <leader>q :wqa<CR>
|
||||
|
||||
|
||||
nmap q :wq!<CR>
|
||||
nmap Q :wqa!<CR>
|
||||
nmap q :BufferLineCycleNext<CR>:BufferLineCloseLeft<CR>
|
||||
nmap Q :qa!<CR>
|
||||
|
||||
" 重新加载设置
|
||||
map R :source ~/.config/nvim/init.vim<CR>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user