Plugin optimization
This commit is contained in:
parent
c520d3ec26
commit
f0c5df79b8
1 changed files with 62 additions and 60 deletions
122
neovim/init.lua
122
neovim/init.lua
|
@ -51,6 +51,9 @@ vim.keymap.set("t", "<c-l>", "<c-\\><c-n><c-w>l", { noremap = true })
|
||||||
|
|
||||||
vim.keymap.set({"i", "n", "t", "v"}, "<F10>", function () vim.cmd("nohlsearch") end)
|
vim.keymap.set({"i", "n", "t", "v"}, "<F10>", function () vim.cmd("nohlsearch") end)
|
||||||
|
|
||||||
|
-- Wrap the function body in an if statement to verify existence of idelayout
|
||||||
|
vim.keymap.set({"n", "t"}, "<leader>z", function () vim.cmd("exec idelayout") end)
|
||||||
|
|
||||||
-- lazy.nvim
|
-- lazy.nvim
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
@ -72,12 +75,11 @@ require("lazy").setup({
|
||||||
lazy = false,
|
lazy = false,
|
||||||
priority = 1000,
|
priority = 1000,
|
||||||
config = function ()
|
config = function ()
|
||||||
vim.cmd([[colorscheme dracula]])
|
vim.cmd.colorscheme("dracula")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
"neovim/nvim-lspconfig",
|
|
||||||
"nvimdev/lspsaga.nvim",
|
"nvimdev/lspsaga.nvim",
|
||||||
"nvim-lualine/lualine.nvim",
|
"nvim-lualine/lualine.nvim",
|
||||||
"nvim-tree/nvim-web-devicons",
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
@ -151,64 +153,6 @@ local lua_ls_setup = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
||||||
|
|
||||||
local lspconfig = require('lspconfig')
|
|
||||||
lspconfig.gopls.setup {capabilities = capabilities}
|
|
||||||
lspconfig.lua_ls.setup(lua_ls_setup)
|
|
||||||
lspconfig.pyright.setup {capabilities = capabilities}
|
|
||||||
lspconfig.tsserver.setup {capabilities = capabilities}
|
|
||||||
lspconfig.rust_analyzer.setup {
|
|
||||||
-- Server-specific settings. See `:help lspconfig-setup`
|
|
||||||
capabilities = capabilities,
|
|
||||||
settings = {
|
|
||||||
['rust-analyzer'] = {},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Global mappings.
|
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
|
||||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { desc = 'Diagnostic: open float' })
|
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Diagnostic: go to previous' })
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Diagnostic: go to next' })
|
|
||||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, { desc = 'Diagnostic: set loclist' })
|
|
||||||
|
|
||||||
-- Use LspAttach autocommand to only map the following keys
|
|
||||||
-- after the language server attaches to the current buffer
|
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
|
||||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
|
||||||
callback = function(ev)
|
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
|
||||||
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
|
||||||
|
|
||||||
-- Buffer local mappings.
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
||||||
local opts = function(desc)
|
|
||||||
return { buffer = ev.buf, desc = desc }
|
|
||||||
end
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts('LSP: go to declaration'))
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts('LSP: go to definition'))
|
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts('LSP: hover'))
|
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts('LSP: go to implementation'))
|
|
||||||
-- This setting steps on my split navigation setting, so I changed it
|
|
||||||
-- to the probably harmless F9.
|
|
||||||
-- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts(''))
|
|
||||||
vim.keymap.set('n', '<F9>', vim.lsp.buf.signature_help, opts('LSP: signature help'))
|
|
||||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts('LSP: add workspace folder'))
|
|
||||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts('LSP: remove workspace folder'))
|
|
||||||
vim.keymap.set('n', '<space>wl', function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, opts('LSP: list workspace folder'))
|
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts('LSP: go to type definition'))
|
|
||||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts('LSP: rename token'))
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts('LSP: code action'))
|
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts('LSP: go to references'))
|
|
||||||
vim.keymap.set('n', '<space>f', function()
|
|
||||||
vim.lsp.buf.format { async = true }
|
|
||||||
end, opts('LSP: format'))
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Set up nvim-cmp.
|
-- Set up nvim-cmp.
|
||||||
local cmp = require'cmp'
|
local cmp = require'cmp'
|
||||||
|
|
||||||
|
@ -271,6 +215,64 @@ cmp.setup.cmdline(':', {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
|
local lspconfig = require('lspconfig')
|
||||||
|
lspconfig.gopls.setup {capabilities = capabilities}
|
||||||
|
lspconfig.lua_ls.setup(lua_ls_setup)
|
||||||
|
lspconfig.pyright.setup {capabilities = capabilities}
|
||||||
|
lspconfig.tsserver.setup {capabilities = capabilities}
|
||||||
|
lspconfig.rust_analyzer.setup {
|
||||||
|
-- Server-specific settings. See `:help lspconfig-setup`
|
||||||
|
capabilities = capabilities,
|
||||||
|
settings = {
|
||||||
|
['rust-analyzer'] = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Global mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { desc = 'Diagnostic: open float' })
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Diagnostic: go to previous' })
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Diagnostic: go to next' })
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, { desc = 'Diagnostic: set loclist' })
|
||||||
|
|
||||||
|
-- Use LspAttach autocommand to only map the following keys
|
||||||
|
-- after the language server attaches to the current buffer
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||||
|
callback = function(ev)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||||
|
|
||||||
|
-- Buffer local mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local opts = function(desc)
|
||||||
|
return { buffer = ev.buf, desc = desc }
|
||||||
|
end
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts('LSP: go to declaration'))
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts('LSP: go to definition'))
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts('LSP: hover'))
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts('LSP: go to implementation'))
|
||||||
|
-- This setting steps on my split navigation setting, so I changed it
|
||||||
|
-- to the probably harmless F9.
|
||||||
|
-- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts(''))
|
||||||
|
vim.keymap.set('n', '<F9>', vim.lsp.buf.signature_help, opts('LSP: signature help'))
|
||||||
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts('LSP: add workspace folder'))
|
||||||
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts('LSP: remove workspace folder'))
|
||||||
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, opts('LSP: list workspace folder'))
|
||||||
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts('LSP: go to type definition'))
|
||||||
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts('LSP: rename token'))
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts('LSP: code action'))
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts('LSP: go to references'))
|
||||||
|
vim.keymap.set('n', '<space>f', function()
|
||||||
|
vim.lsp.buf.format { async = true }
|
||||||
|
end, opts('LSP: format'))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
require('gitsigns').setup({
|
require('gitsigns').setup({
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = '│' },
|
add = { text = '│' },
|
||||||
|
|
Loading…
Reference in a new issue