Merge pull request #33 from qwjyh/refactor-nvim-config
Refactor nvim config
This commit is contained in:
commit
fe1f4d22e4
4 changed files with 43 additions and 70 deletions
|
@ -54,6 +54,7 @@ scoop import .\bin\windows\scoop_apps\scoop_minimal_apps.json
|
|||
New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\init.lua -Target (Resolve-Path .\dotfiles\neovim\init.lua) -Force
|
||||
New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lualine_setup.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lualine_setup.lua) -Force
|
||||
New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\term_powershell.lua -Target (Resolve-Path .\dotfiles\neovim\lua\term_powershell.lua) -Force
|
||||
New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lsp_config.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lsp_config.lua) -Force
|
||||
New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lspconfig\server_configurations\satysfi_ls.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lspconfig\server_configurations\satysfi_ls.lua) -Force
|
||||
mkdir $env:LOCALAPPDATA\nvim\after\ftplugin
|
||||
New-Item -ItemType SymbolicLink -Path $env:LOCALAPPDATA\nvim\after\ftplugin\satysfi.lua -Target (Resolve-Path .\dotfiles\neovim\after\ftplugin\satysfi.lua)
|
||||
|
|
|
@ -25,6 +25,7 @@ ln -sf $(pwd)/dotfiles/neovim/init.lua ~/.config/nvim/init.lua
|
|||
mkdir -p ~/.config/nvim/lua
|
||||
ln -sf $(pwd)/dotfiles/neovim/lua/lualine_setup.lua ~/.config/nvim/lua/lualine_setup.lua
|
||||
ln -sf $(pwd)/dotfiles/neovim/lua/term_powershell.lua ~/.config/nvim/lua/term_powershell.lua
|
||||
ln -sf $(pwd)/dotfiles/neovim/lua/lsp_config.lua ~/.config/nvim/lua/lsp_config.lua
|
||||
ln -sf $(pwd)/dotfiles/neovim/lua/pluto_nvim.lua ~/.config/nvim/lua/pluto_nvim.lua
|
||||
mkdir -p ~/.config/nvim/lua/lspconfig/server_configurations
|
||||
ln -sf $(pwd)/dotfiles/neovim/lua/lspconfig/server_configurations/satysfi_ls.lua ~/.config/nvim/lua/lspconfig/server_configurations/satysfi_ls.lua
|
||||
|
|
|
@ -125,14 +125,6 @@ require('lazy').setup({
|
|||
},
|
||||
{
|
||||
"andymass/vim-matchup",
|
||||
config = function()
|
||||
vim.g.matchup_matchparen_offscreen = { method = "popup" }
|
||||
require 'nvim-treesitter.configs'.setup {
|
||||
matchup = {
|
||||
enable = true,
|
||||
}
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
|
@ -196,29 +188,7 @@ require('lazy').setup({
|
|||
-- see Julian/lean.nvim readme
|
||||
opts = {
|
||||
lsp = {
|
||||
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 function
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'g1', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set('n', 'grf', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||
end,
|
||||
on_attach = require("lsp_config").on_attach,
|
||||
},
|
||||
mappings = true,
|
||||
},
|
||||
|
@ -234,15 +204,6 @@ require('lazy').setup({
|
|||
},
|
||||
-- event = 'VeryLazy', -- doesn't work with existing comp and treesitter
|
||||
config = function()
|
||||
-- Setup treesitter
|
||||
require('nvim-treesitter.configs').setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = { 'org' },
|
||||
},
|
||||
ensure_installed = { 'org' },
|
||||
})
|
||||
|
||||
-- Setup orgmode
|
||||
require('orgmode').setup({
|
||||
org_agenda_files = '~/orgfiles/**/*',
|
||||
|
@ -462,7 +423,7 @@ require('gitsigns').setup {
|
|||
---@param mode string|string[]
|
||||
---@param l string
|
||||
---@param r any
|
||||
---@param opts table?
|
||||
---@param opts vim.keymap.set.Opts?
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
|
@ -624,30 +585,7 @@ vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
|||
|
||||
-- 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 function
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'g1', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set('n', 'grf', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||
end
|
||||
local on_attach = require("lsp_config").on_attach
|
||||
|
||||
-- cmp_nvim_lsp supports additional LSP completion capabilities
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
@ -759,11 +697,7 @@ lspconfig.powershell_es.setup {
|
|||
bundle_path = vim.fn.has('win32') == 1 and win_pwsh_es_path or arch_pwsh_es_path,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- ccls
|
||||
-- -- csharp
|
||||
-- lspconfig.omnisharp.setup {
|
||||
-- cmd = {'omnisharp'},
|
||||
-- }
|
||||
|
||||
|
||||
lspconfig.tinymist.setup {
|
||||
on_attach = on_attach,
|
||||
|
|
37
dotfiles/neovim/lua/lsp_config.lua
Normal file
37
dotfiles/neovim/lua/lsp_config.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
local M = {}
|
||||
|
||||
---Add `desc` to bufopts table.
|
||||
---@param bufopts vim.keymap.set.Opts
|
||||
---@param desc string
|
||||
---@return vim.keymap.set.Opts
|
||||
local function with_desc(bufopts, desc)
|
||||
return vim.tbl_extend("error", bufopts, { desc = desc })
|
||||
end
|
||||
|
||||
M.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 function
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, with_desc(bufopts, "goto declaration"))
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, with_desc(bufopts, "goto definition"))
|
||||
vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, with_desc(bufopts, "goto type definition"))
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, with_desc(bufopts, "lsp hover"))
|
||||
vim.keymap.set('n', 'g1', vim.lsp.buf.implementation, with_desc(bufopts, "lsp implementations"))
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, with_desc(bufopts, "lsp signature help"))
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, with_desc(bufopts, "lsp add_workspace_folder"))
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder,
|
||||
with_desc(bufopts, "lsp remove_workspace_folder"))
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, with_desc(bufopts, "lsp list_workspace_folders"))
|
||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, with_desc(bufopts, "lsp type definition"))
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, with_desc(bufopts, "lsp rename"))
|
||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, with_desc(bufopts, "lsp code_action"))
|
||||
vim.keymap.set('n', 'grf', vim.lsp.buf.references, with_desc(bufopts, "lsp references"))
|
||||
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, with_desc(bufopts, "lsp format"))
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Reference in a new issue