From 5b562a12dae1928f4a05f257410f9f006617617f Mon Sep 17 00:00:00 2001 From: Dmitry Chumak Date: Thu, 13 Mar 2025 19:48:19 +0300 Subject: [PATCH] [nvim] gitsigns --- nvim/init.lua | 1 + nvim/lua/funcs.lua | 8 ++++++++ nvim/lua/lsp-config.lua | 2 ++ nvim/lua/options.lua | 6 ++++++ nvim/lua/plugins/gitsigns.lua | 22 ++++++++++++++++++++++ nvim/lua/plugins/init.lua | 6 ++++++ 6 files changed, 45 insertions(+) create mode 100644 nvim/lua/funcs.lua create mode 100644 nvim/lua/plugins/gitsigns.lua diff --git a/nvim/init.lua b/nvim/init.lua index a7420d9..d97f61a 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,3 +1,4 @@ +require("funcs") require("options") require("keymap") require("plugins/init") diff --git a/nvim/lua/funcs.lua b/nvim/lua/funcs.lua new file mode 100644 index 0000000..3249165 --- /dev/null +++ b/nvim/lua/funcs.lua @@ -0,0 +1,8 @@ +function Contains(list, element) + for _, v in ipairs(list) do + if element == v then + return true + end + end + return false +end diff --git a/nvim/lua/lsp-config.lua b/nvim/lua/lsp-config.lua index 748e5ae..1cc1ddf 100644 --- a/nvim/lua/lsp-config.lua +++ b/nvim/lua/lsp-config.lua @@ -113,6 +113,8 @@ require("lspconfig").bashls.setup { capabilities = capabilities, handlers = hand } require("lspconfig").pyright.setup { capabilities = capabilities, handlers = handlers, on_attach = on_attach, + -- more details on configuring pyright can be found here + -- https://microsoft.github.io/pyright/#/settings?id=pyright-settings settings = { python = { analysis = { diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua index 5559698..98ac931 100644 --- a/nvim/lua/options.lua +++ b/nvim/lua/options.lua @@ -1,3 +1,5 @@ +IsYandex = Contains({"i113855042", "dmchumak-dev.sas.yp-c.yandex.net"}, vim.fn.hostname()) + vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' @@ -28,3 +30,7 @@ vim.keymap.set("n", "", "h") vim.keymap.set("n", "", "j") vim.keymap.set("n", "", "k") vim.keymap.set("n", "", "l") + +-- Keymap to copy to system buffer +vim.keymap.set('n','y','"+yy') +vim.keymap.set('v','y','"+y') diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..e564a26 --- /dev/null +++ b/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,22 @@ +require('gitsigns').setup( + { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = '▀' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = '▀' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + } +) + +vim.keymap.set('n', 'vb', ':Gitsigns blame_line', {desc = "Blame current line (git/arc)"}) diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index cde932d..bacd939 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -64,6 +64,11 @@ local plugins = { desc = "Buffer Local Keymaps (which-key)", }, }, + }, + -- GitSigns + { + dir = (IsYandex) and "~/arcadia/contrib/tier1/gitsigns.arc.nvim" or nil, + url = (not IsYandex) and "lewis6991/gitsigns.nvim" or nil, } } @@ -71,3 +76,4 @@ require("lazy").setup(plugins) require("plugins/telescope") require("plugins/completions") +require("plugins/gitsigns")