ref(nvim): plugins

This commit is contained in:
thek4n 2024-07-02 10:02:01 +03:00
parent c5676ebb4e
commit c7deca5a68
5 changed files with 62 additions and 54 deletions

View File

@ -91,6 +91,13 @@ map("n", '<Leader>he', '<cmd>set list!<CR>',
vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]] vim.opt.listchars=[[tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶]]
map("n", "<Leader>pl", "<cmd>Lazy<CR>",
{desc = "Package manager"})
map("n", "<Leader>pm", "<cmd>Mason<CR>",
{desc = "LSP Manager"})
-- Tab to go prev buffer -- Tab to go prev buffer
map("n", "<TAB>", ":b#<CR>", {silent = true}) map("n", "<TAB>", ":b#<CR>", {silent = true})
@ -127,34 +134,6 @@ function toggle_number_style()
end end
local function set_trouble_keymap(key, cmd)
map("n", string.format("<space>x%s", key), string.format("<cmd>TroubleToggle %s<CR>", cmd))
end
set_trouble_keymap("x", "")
set_trouble_keymap("w", "workspace_diagnostics") -- lsp diagnostic of workspace
set_trouble_keymap("d", "document_diagnostics") -- diagnostic of current file
local function set_gitsigns_keymap(key, cmd)
map("n", string.format("<space>g%s", key), string.format("<cmd>Gitsigns %s<CR>", cmd))
end
set_gitsigns_keymap('p', 'preview_hunk') -- show diff
set_gitsigns_keymap('b', 'blame_line') -- show author, hash, date and message of current line commit
set_gitsigns_keymap('n', 'next_hunk') -- go to next unstaged changes
set_gitsigns_keymap('N', 'prev_hunk') -- go to prev unstaged changes
set_gitsigns_keymap('r', 'reset_hunk') -- reset hunk under cursor
set_gitsigns_keymap('h', 'toggle_linehl') -- line highlighting
map("n", "<Leader>pl", "<cmd>Lazy<CR>",
{desc = "Package manager"})
map("n", "<Leader>pm", "<cmd>Mason<CR>",
{desc = "LSP Manager"})
local function reload_config() local function reload_config()
vim.cmd.source(vim.env.MYVIMRC) vim.cmd.source(vim.env.MYVIMRC)
vim.notify('Config reloaded...', vim.log.levels.INFO) vim.notify('Config reloaded...', vim.log.levels.INFO)

View File

@ -98,4 +98,57 @@ return {
}) })
end end
}, },
{
'folke/trouble.nvim',
dependencies = { 'kyazdani42/nvim-web-devicons' },
config = function()
require("trouble").setup()
local function set_trouble_keymap(key, cmd)
vim.keymap.set(
"n",
string.format("<space>x%s", key),
string.format("<cmd>Trouble %s<CR>", cmd)
)
end
set_trouble_keymap("x", "diagnostics toggle")
set_trouble_keymap("X", "diagnostics toggle filter.buf=0")
set_trouble_keymap("Q", "qflist toggle")
set_trouble_keymap("l", "lsp toggle focus=false win.position=right")
end
},
{
'lewis6991/gitsigns.nvim',
event = "BufReadPost",
enabled = vim.fn.executable "git" == 1,
config = function()
require("gitsigns").setup({
signs = {
add = { text = "+" },
change = { text = "|" },
delete = { text = "-" },
topdelete = { text = "^" },
changedelete = { text = "~" },
untracked = { text = "0" },
}
})
local function set_gitsigns_keymap(key, cmd)
vim.keymap.set(
"n",
string.format("<space>g%s", key),
string.format("<cmd>Gitsigns %s<CR>", cmd)
)
end
set_gitsigns_keymap('p', 'preview_hunk') -- show diff
set_gitsigns_keymap('b', 'blame_line') -- show author, hash, date and message of current line commit
set_gitsigns_keymap('n', 'next_hunk') -- go to next unstaged changes
set_gitsigns_keymap('N', 'prev_hunk') -- go to prev unstaged changes
set_gitsigns_keymap('r', 'reset_hunk') -- reset hunk under cursor
set_gitsigns_keymap('h', 'toggle_linehl') -- line highlighting
end
}
} }

View File

@ -1,17 +0,0 @@
return {
'lewis6991/gitsigns.nvim',
event = "BufReadPost",
enabled = vim.fn.executable "git" == 1,
config = function()
require("gitsigns").setup({
signs = {
add = { text = "+" },
change = { text = "|" },
delete = { text = "-" },
topdelete = { text = "^" },
changedelete = { text = "~" },
untracked = { text = "0" },
}
})
end
}

View File

@ -1,9 +1,9 @@
local on_attach = function(_, bufnr) local on_attach = function(_, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_get_option_value(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_set_option_value(...) end
-- Enable completion triggered by <c-x><c-o> -- 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. -- Mappings.
local opts = { noremap=true, silent=true } local opts = { noremap=true, silent=true }

View File

@ -44,13 +44,6 @@ return {
}) })
end end
}, },
{
'folke/trouble.nvim',
dependencies = { 'kyazdani42/nvim-web-devicons' },
config = function()
require("trouble").setup()
end
},
{ {
"thek4n/mdimage.nvim", "thek4n/mdimage.nvim",
config = function() config = function()