[neovim] Some tweaks
This commit is contained in:
parent
7153792ade
commit
8ed7eab826
1 changed files with 315 additions and 266 deletions
581
neovim/init.lua
581
neovim/init.lua
|
@ -6,7 +6,7 @@ vim.opt.clipboard = "unnamedplus,unnamed"
|
||||||
|
|
||||||
-- Spaces indentation
|
-- Spaces indentation
|
||||||
vim.opt.expandtab = true -- converts tabs to spaces
|
vim.opt.expandtab = true -- converts tabs to spaces
|
||||||
vim.opt.tabstop = 4 -- tab equals 2 spaces
|
vim.opt.tabstop = 4 -- tab equals 4 spaces
|
||||||
vim.opt.shiftwidth = 4 -- indent size in characters
|
vim.opt.shiftwidth = 4 -- indent size in characters
|
||||||
|
|
||||||
-- Show whitespace (:list)
|
-- Show whitespace (:list)
|
||||||
|
@ -23,7 +23,7 @@ vim.opt.cursorline = true
|
||||||
|
|
||||||
-- Enable folding
|
-- Enable folding
|
||||||
vim.opt.foldmethod = "syntax"
|
vim.opt.foldmethod = "syntax"
|
||||||
vim.opt.foldlevel = 0
|
vim.opt.foldlevel = 5
|
||||||
|
|
||||||
-- Enable 24-bit RGB color in the TUI
|
-- Enable 24-bit RGB color in the TUI
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
|
@ -49,104 +49,112 @@ vim.keymap.set("n", "<c-h>", "<c-w>h", { noremap = true, desc = 'Go to window to
|
||||||
vim.keymap.set("t", "<c-j>", "<c-\\><c-n><c-w>j", { noremap = true, desc = 'Go to window below' })
|
vim.keymap.set("t", "<c-j>", "<c-\\><c-n><c-w>j", { noremap = true, desc = 'Go to window below' })
|
||||||
vim.keymap.set("t", "<c-k>", "<c-\\><c-n><c-w>k", { noremap = true, desc = 'Go to window above' })
|
vim.keymap.set("t", "<c-k>", "<c-\\><c-n><c-w>k", { noremap = true, desc = 'Go to window above' })
|
||||||
vim.keymap.set("t", "<c-h>", "<c-\\><c-n><c-w>h", { noremap = true, desc = 'Go to window to the left' })
|
vim.keymap.set("t", "<c-h>", "<c-\\><c-n><c-w>h", { noremap = true, desc = 'Go to window to the left' })
|
||||||
vim.keymap.set("t", "<c-l>", "<c-\\><c-n><c-w>l", { noremap = true, desc = 'Go to window to the right' })
|
-- vim.keymap.set("t", "<c-l>", "<c-\\><c-n><c-w>l", { noremap = true, desc = 'Go to window to the right' })
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
vim.keymap.set(
|
vim.keymap.set(
|
||||||
{"i", "n", "t", "v"},
|
{"i", "n", "t", "v"},
|
||||||
"<F10>",
|
"<F10>",
|
||||||
function ()
|
function ()
|
||||||
vim.cmd("nohlsearch")
|
vim.cmd("nohlsearch")
|
||||||
end,
|
end,
|
||||||
{ desc = ":nohlsearch" }
|
{ desc = ":nohlsearch" }
|
||||||
)
|
)
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
vim.keymap.set(
|
vim.keymap.set(
|
||||||
{"n", "t"},
|
{"n", "t"},
|
||||||
"<leader>z",
|
"<leader>z",
|
||||||
function ()
|
function ()
|
||||||
-- This restores the UI to the saved layout 'idelayout' (if saved on command line)
|
-- This restores the UI to the saved layout 'idelayout' (if saved on command line)
|
||||||
-- TODO: Wrap the function body in an if statement to verify existence of idelayout
|
-- TODO: Wrap the function body in an if statement to verify existence of idelayout
|
||||||
vim.cmd("exec idelayout")
|
vim.cmd("exec idelayout")
|
||||||
end,
|
end,
|
||||||
{ desc = "Revert window layout" }
|
{ desc = "Revert window layout" }
|
||||||
)
|
)
|
||||||
|
|
||||||
-- 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
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
"git",
|
"git",
|
||||||
"clone",
|
"clone",
|
||||||
"--filter=blob:none",
|
"--filter=blob:none",
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
"--branch=stable", -- latest stable release
|
"--branch=stable", -- latest stable release
|
||||||
lazypath,
|
lazypath,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
{
|
{
|
||||||
url = "https://git.theadamcooper.com/adam/dracula-vim.git",
|
url = "https://git.theadamcooper.com/adam/dracula-vim.git",
|
||||||
branch = "adamc-main",
|
branch = "adamc-main",
|
||||||
name = "dracula",
|
name = "dracula",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
priority = 1000,
|
priority = 1000,
|
||||||
config = function ()
|
config = function ()
|
||||||
vim.cmd.colorscheme("dracula")
|
vim.cmd.colorscheme("dracula")
|
||||||
end,
|
end,
|
||||||
},
|
|
||||||
{
|
|
||||||
"kylechui/nvim-surround",
|
|
||||||
version = "*", -- Use for stability; omit to use `main` branch for the latest features
|
|
||||||
event = "VeryLazy",
|
|
||||||
config = function()
|
|
||||||
require("nvim-surround").setup({
|
|
||||||
-- Configuration here, or leave empty to use defaults
|
|
||||||
})
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"folke/which-key.nvim",
|
|
||||||
event = "VeryLazy",
|
|
||||||
init = function()
|
|
||||||
vim.o.timeout = true
|
|
||||||
-- N.B. Setting `timeoutlen` to 0 seems to break the plugin
|
|
||||||
vim.o.timeoutlen = 300 -- 0? 500? 300?
|
|
||||||
end,
|
|
||||||
opts = {
|
|
||||||
window = {
|
|
||||||
border = "single",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
"kylechui/nvim-surround",
|
||||||
"ray-x/lsp_signature.nvim",
|
version = "*", -- Use for stability; omit to use `main` branch for the latest features
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = {},
|
config = function()
|
||||||
config = function(_, opts) require'lsp_signature'.setup(opts) end
|
require("nvim-surround").setup({
|
||||||
},
|
-- Configuration here, or leave empty to use defaults
|
||||||
"williamboman/mason.nvim",
|
})
|
||||||
"williamboman/mason-lspconfig.nvim",
|
end
|
||||||
"nvimdev/lspsaga.nvim",
|
},
|
||||||
"nvim-lualine/lualine.nvim",
|
{
|
||||||
"nvim-tree/nvim-web-devicons",
|
"folke/which-key.nvim",
|
||||||
"nvim-lua/plenary.nvim",
|
event = "VeryLazy",
|
||||||
{ "nvim-telescope/telescope.nvim", branch = "0.1.x" },
|
init = function()
|
||||||
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
|
vim.o.timeout = true
|
||||||
"neovim/nvim-lspconfig",
|
-- N.B. Setting `timeoutlen` to 0 seems to break the plugin
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
vim.o.timeoutlen = 300 -- 0? 500? 300?
|
||||||
"hrsh7th/cmp-buffer",
|
end,
|
||||||
"hrsh7th/cmp-path",
|
opts = {
|
||||||
"hrsh7th/cmp-cmdline",
|
window = {
|
||||||
"hrsh7th/nvim-cmp",
|
border = "single",
|
||||||
"hrsh7th/cmp-vsnip",
|
},
|
||||||
"hrsh7th/vim-vsnip",
|
},
|
||||||
"hrsh7th/cmp-nvim-lsp-signature-help",
|
},
|
||||||
"tpope/vim-fugitive",
|
{
|
||||||
"lewis6991/gitsigns.nvim",
|
"ray-x/lsp_signature.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {},
|
||||||
|
config = function(_, opts) require'lsp_signature'.setup(opts) end
|
||||||
|
},
|
||||||
|
"mfussenegger/nvim-dap",
|
||||||
|
{ "mxsdev/nvim-dap-vscode-js", requires = "mfussenegger/nvim-dap" },
|
||||||
|
{
|
||||||
|
"microsoft/vscode-js-debug",
|
||||||
|
opt = true,
|
||||||
|
run = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out",
|
||||||
|
},
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
"nvimdev/lspsaga.nvim",
|
||||||
|
"nvim-lualine/lualine.nvim",
|
||||||
|
"nvim-tree/nvim-web-devicons",
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
{ "nvim-telescope/telescope.nvim", branch = "0.1.x" },
|
||||||
|
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"hrsh7th/cmp-cmdline",
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
"hrsh7th/cmp-vsnip",
|
||||||
|
"hrsh7th/vim-vsnip",
|
||||||
|
"hrsh7th/cmp-nvim-lsp-signature-help",
|
||||||
|
"tpope/vim-fugitive",
|
||||||
|
"lewis6991/gitsigns.nvim",
|
||||||
|
"famiu/bufdelete.nvim",
|
||||||
})
|
})
|
||||||
|
|
||||||
--[[ mason
|
--[[ mason
|
||||||
|
@ -162,15 +170,15 @@ Lualine provides the status bar as well as the tabline. Not sure whether
|
||||||
it also provides the buffer breadcrumbs.
|
it also provides the buffer breadcrumbs.
|
||||||
--]]
|
--]]
|
||||||
require('lualine').setup {
|
require('lualine').setup {
|
||||||
options = { theme = 'dracula' },
|
options = { theme = 'dracula' },
|
||||||
tabline = {
|
tabline = {
|
||||||
lualine_a = {
|
lualine_a = {
|
||||||
{
|
{
|
||||||
'buffers',
|
'buffers',
|
||||||
mode = 4,
|
mode = 4,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--[[ Telescope
|
--[[ Telescope
|
||||||
|
@ -192,62 +200,62 @@ nvim-cmp is a text completion engine.
|
||||||
local cmp = require'cmp'
|
local cmp = require'cmp'
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp_signature_help' }
|
{ name = 'nvim_lsp_signature_help' }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
-- REQUIRED - you must specify a snippet engine
|
-- REQUIRED - you must specify a snippet engine
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
window = {
|
window = {
|
||||||
completion = cmp.config.window.bordered(),
|
completion = cmp.config.window.bordered(),
|
||||||
documentation = cmp.config.window.bordered(),
|
documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = 'vsnip' }, -- For vsnip users.
|
{ name = 'vsnip' }, -- For vsnip users.
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set configuration for specific filetype.
|
-- Set configuration for specific filetype.
|
||||||
cmp.setup.filetype('gitcommit', {
|
cmp.setup.filetype('gitcommit', {
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'buffer' }
|
{ name = 'buffer' }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline(':', {
|
cmp.setup.cmdline(':', {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'path' }
|
{ name = 'path' }
|
||||||
}, {
|
}, {
|
||||||
{ name = 'cmdline' }
|
{ name = 'cmdline' }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
--[[ nvim-lspconfig
|
--[[ nvim-lspconfig
|
||||||
|
@ -255,27 +263,27 @@ cmp.setup.cmdline(':', {
|
||||||
|
|
||||||
-- Setup language servers.
|
-- Setup language servers.
|
||||||
local lua_ls_setup = {
|
local lua_ls_setup = {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
version = "LuaJIT",
|
version = "LuaJIT",
|
||||||
|
},
|
||||||
|
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),
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
-- Do not send telemetry data containing a randomized but unique identifier
|
||||||
|
telemetry = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
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),
|
|
||||||
checkThirdParty = false,
|
|
||||||
},
|
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
|
||||||
telemetry = {
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
@ -286,11 +294,11 @@ lspconfig.lua_ls.setup(lua_ls_setup)
|
||||||
lspconfig.pyright.setup {capabilities = capabilities}
|
lspconfig.pyright.setup {capabilities = capabilities}
|
||||||
lspconfig.tsserver.setup {capabilities = capabilities}
|
lspconfig.tsserver.setup {capabilities = capabilities}
|
||||||
lspconfig.rust_analyzer.setup {
|
lspconfig.rust_analyzer.setup {
|
||||||
-- Server-specific settings. See `:help lspconfig-setup`
|
-- Server-specific settings. See `:help lspconfig-setup`
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
settings = {
|
settings = {
|
||||||
['rust-analyzer'] = {},
|
['rust-analyzer'] = {},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Global mappings : Diagnostics
|
-- Global mappings : Diagnostics
|
||||||
|
@ -303,127 +311,127 @@ vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, { desc = 'Diagnostic:
|
||||||
-- Use LspAttach autocommand to only map the following keys
|
-- Use LspAttach autocommand to only map the following keys
|
||||||
-- after the language server attaches to the current buffer
|
-- after the language server attaches to the current buffer
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||||
|
|
||||||
-- Buffer local mappings.
|
-- Buffer local mappings.
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
local opts = function(desc)
|
local opts = function(desc)
|
||||||
return { buffer = ev.buf, desc = desc }
|
return { buffer = ev.buf, desc = desc }
|
||||||
end
|
end
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts('LSP: go to declaration'))
|
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', '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', 'K', vim.lsp.buf.hover, opts('LSP: hover'))
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts('LSP: go to implementation'))
|
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
|
-- This setting steps on my split navigation setting, so I changed it
|
||||||
-- to the probably harmless F9.
|
-- to the probably harmless F9.
|
||||||
-- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts(''))
|
-- 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', '<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>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>wr', vim.lsp.buf.remove_workspace_folder, opts('LSP: remove workspace folder'))
|
||||||
vim.keymap.set('n', '<space>wl', function()
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
end, opts('LSP: list workspace folder'))
|
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>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', '<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', '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', 'gr', vim.lsp.buf.references, opts('LSP: go to references'))
|
||||||
vim.keymap.set('n', '<space>f', function()
|
vim.keymap.set('n', '<space>f', function()
|
||||||
vim.lsp.buf.format { async = true }
|
vim.lsp.buf.format { async = true }
|
||||||
end, opts('LSP: format'))
|
end, opts('LSP: format'))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
require('gitsigns').setup({
|
require('gitsigns').setup({
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = '│' },
|
add = { text = '│' },
|
||||||
change = { text = '│' },
|
change = { text = '│' },
|
||||||
delete = { text = '_' },
|
delete = { text = '_' },
|
||||||
topdelete = { text = '‾' },
|
topdelete = { text = '‾' },
|
||||||
changedelete = { text = '~' },
|
changedelete = { text = '~' },
|
||||||
untracked = { text = '┆' },
|
untracked = { text = '┆' },
|
||||||
},
|
},
|
||||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||||
watch_gitdir = {
|
watch_gitdir = {
|
||||||
follow_files = true
|
follow_files = true
|
||||||
},
|
},
|
||||||
attach_to_untracked = true,
|
attach_to_untracked = true,
|
||||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||||
current_line_blame_opts = {
|
current_line_blame_opts = {
|
||||||
virt_text = true,
|
virt_text = true,
|
||||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||||
delay = 1000,
|
delay = 1000,
|
||||||
ignore_whitespace = false,
|
ignore_whitespace = false,
|
||||||
},
|
},
|
||||||
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
|
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
|
||||||
sign_priority = 6,
|
sign_priority = 6,
|
||||||
update_debounce = 100,
|
update_debounce = 100,
|
||||||
status_formatter = nil, -- Use default
|
status_formatter = nil, -- Use default
|
||||||
max_file_length = 40000, -- Disable if file is longer than this (in lines)
|
max_file_length = 40000, -- Disable if file is longer than this (in lines)
|
||||||
preview_config = {
|
preview_config = {
|
||||||
-- Options passed to nvim_open_win
|
-- Options passed to nvim_open_win
|
||||||
border = 'single',
|
border = 'single',
|
||||||
style = 'minimal',
|
style = 'minimal',
|
||||||
relative = 'cursor',
|
relative = 'cursor',
|
||||||
row = 0,
|
row = 0,
|
||||||
col = 1
|
col = 1
|
||||||
},
|
},
|
||||||
yadm = {
|
yadm = {
|
||||||
enable = false
|
enable = false
|
||||||
},
|
},
|
||||||
on_attach = function(bufnr)
|
on_attach = function(bufnr)
|
||||||
local gs = package.loaded.gitsigns
|
local gs = package.loaded.gitsigns
|
||||||
|
|
||||||
|
local function map(mode, l, r, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.buffer = bufnr
|
||||||
|
vim.keymap.set(mode, l, r, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Navigation
|
||||||
|
map('n', ']c', function()
|
||||||
|
if vim.wo.diff then return ']c' end
|
||||||
|
vim.schedule(function() gs.next_hunk() end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, {expr=true, desc='GitSigns: go to next hunk'})
|
||||||
|
|
||||||
|
map('n', '[c', function()
|
||||||
|
if vim.wo.diff then return '[c' end
|
||||||
|
vim.schedule(function() gs.prev_hunk() end)
|
||||||
|
return '<Ignore>'
|
||||||
|
end, {expr=true, desc='GitSigns: go to previous hunk'})
|
||||||
|
|
||||||
|
-- Actions
|
||||||
|
map('n', '<leader>hs', gs.stage_hunk, { desc = 'GitSigns: stage hunk' })
|
||||||
|
map('n', '<leader>hr', gs.reset_hunk, { desc = 'GitSigns: reset hunk' })
|
||||||
|
map('v', '<leader>hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = 'GitSigns: stage hunk' })
|
||||||
|
map('v', '<leader>hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = 'GitSigns: reset hunk' })
|
||||||
|
map('n', '<leader>hS', gs.stage_buffer, { desc = 'GitSigns: stage buffer' })
|
||||||
|
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'GitSigns: undo stage hunk' })
|
||||||
|
map('n', '<leader>hR', gs.reset_buffer, { desc = 'GitSigns: reset_buffer' })
|
||||||
|
map('n', '<leader>hp', gs.preview_hunk, { desc = 'GitSigns: preview hunk' })
|
||||||
|
map('n', '<leader>hb', function() gs.blame_line{full=true} end, { desc = 'GitSigns: blame line' })
|
||||||
|
map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'GitSigns: toggle current line blame' })
|
||||||
|
map('n', '<leader>hd', gs.diffthis, { desc = 'GitSigns: diff this' })
|
||||||
|
map('n', '<leader>hD', function() gs.diffthis('~') end, { desc = 'GitSigns: diff this' })
|
||||||
|
map('n', '<leader>td', gs.toggle_deleted, { desc = 'GitSigns: toggle deleted' })
|
||||||
|
|
||||||
local function map(mode, l, r, opts)
|
|
||||||
opts = opts or {}
|
|
||||||
opts.buffer = bufnr
|
|
||||||
vim.keymap.set(mode, l, r, opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Navigation
|
|
||||||
map('n', ']c', function()
|
|
||||||
if vim.wo.diff then return ']c' end
|
|
||||||
vim.schedule(function() gs.next_hunk() end)
|
|
||||||
return '<Ignore>'
|
|
||||||
end, {expr=true, desc='GitSigns: go to next hunk'})
|
|
||||||
|
|
||||||
map('n', '[c', function()
|
|
||||||
if vim.wo.diff then return '[c' end
|
|
||||||
vim.schedule(function() gs.prev_hunk() end)
|
|
||||||
return '<Ignore>'
|
|
||||||
end, {expr=true, desc='GitSigns: go to previous hunk'})
|
|
||||||
|
|
||||||
-- Actions
|
|
||||||
map('n', '<leader>hs', gs.stage_hunk, { desc = 'GitSigns: stage hunk' })
|
|
||||||
map('n', '<leader>hr', gs.reset_hunk, { desc = 'GitSigns: reset hunk' })
|
|
||||||
map('v', '<leader>hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = 'GitSigns: stage hunk' })
|
|
||||||
map('v', '<leader>hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end, { desc = 'GitSigns: reset hunk' })
|
|
||||||
map('n', '<leader>hS', gs.stage_buffer, { desc = 'GitSigns: stage buffer' })
|
|
||||||
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'GitSigns: undo stage hunk' })
|
|
||||||
map('n', '<leader>hR', gs.reset_buffer, { desc = 'GitSigns: reset_buffer' })
|
|
||||||
map('n', '<leader>hp', gs.preview_hunk, { desc = 'GitSigns: preview hunk' })
|
|
||||||
map('n', '<leader>hb', function() gs.blame_line{full=true} end, { desc = 'GitSigns: blame line' })
|
|
||||||
map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'GitSigns: toggle current line blame' })
|
|
||||||
map('n', '<leader>hd', gs.diffthis, { desc = 'GitSigns: diff this' })
|
|
||||||
map('n', '<leader>hD', function() gs.diffthis('~') end, { desc = 'GitSigns: diff this' })
|
|
||||||
map('n', '<leader>td', gs.toggle_deleted, { desc = 'GitSigns: toggle deleted' })
|
|
||||||
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
-- LSPSaga : provides a diverse basket of utilities
|
-- LSPSaga : provides a diverse basket of utilities
|
||||||
--]]
|
--]]
|
||||||
require('lspsaga').setup({
|
require('lspsaga').setup({
|
||||||
beacon = {
|
beacon = {
|
||||||
enable = true,
|
enable = true,
|
||||||
frequency = 7,
|
frequency = 7,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
vim.keymap.set('n', '<leader>si', '<cmd>Lspsaga incoming_calls<CR>')
|
vim.keymap.set('n', '<leader>si', '<cmd>Lspsaga incoming_calls<CR>')
|
||||||
vim.keymap.set('n', '<leader>so', '<cmd>Lspsaga outgoing_calls<CR>')
|
vim.keymap.set('n', '<leader>so', '<cmd>Lspsaga outgoing_calls<CR>')
|
||||||
|
@ -441,6 +449,47 @@ vim.keymap.set('n', '<leader>sl', '<cmd>Lspsaga outline<CR>')
|
||||||
vim.keymap.set('n', '<leader>rn', '<cmd>Lspsaga rename<CR>')
|
vim.keymap.set('n', '<leader>rn', '<cmd>Lspsaga rename<CR>')
|
||||||
vim.keymap.set('n', '<leader>st', '<cmd>Lspsaga term_toggle<CR>')
|
vim.keymap.set('n', '<leader>st', '<cmd>Lspsaga term_toggle<CR>')
|
||||||
|
|
||||||
|
-- setup adapters
|
||||||
|
require('dap-vscode-js').setup({
|
||||||
|
debugger_path = vim.fn.stdpath('data') .. '/mason/packages/js-debug-adapter',
|
||||||
|
debugger_cmd = { 'js-debug-adapter' },
|
||||||
|
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
|
||||||
|
})
|
||||||
|
|
||||||
|
local dap = require('dap')
|
||||||
|
for _, language in ipairs({ "typescript", "javascript" }) do
|
||||||
|
dap.configurations[language] = {
|
||||||
|
{
|
||||||
|
type = "pwa-node",
|
||||||
|
request = "launch",
|
||||||
|
name = "Launch file",
|
||||||
|
program = "${file}",
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "pwa-node",
|
||||||
|
request = "attach",
|
||||||
|
name = "Attach",
|
||||||
|
processId = require'dap.utils'.pick_process,
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "pwa-node",
|
||||||
|
request = "launch",
|
||||||
|
name = "Debug Mocha Tests",
|
||||||
|
-- trace = true, -- include debugger info
|
||||||
|
runtimeExecutable = "node",
|
||||||
|
runtimeArgs = {
|
||||||
|
"./node_modules/mocha/bin/mocha.js",
|
||||||
|
},
|
||||||
|
rootPath = "${workspaceFolder}",
|
||||||
|
cwd = "${workspaceFolder}",
|
||||||
|
console = "integratedTerminal",
|
||||||
|
internalConsoleOptions = "neverOpen",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-- Tweak GitSigns blame color
|
-- Tweak GitSigns blame color
|
||||||
-- This differentiates the cursorline from the git blame text
|
-- This differentiates the cursorline from the git blame text
|
||||||
vim.cmd("highlight GitSignsCurrentLineBlame gui=bold guifg=#339944")
|
vim.cmd("highlight GitSignsCurrentLineBlame gui=bold guifg=#339944")
|
||||||
|
|
Loading…
Reference in a new issue