From b3b051355ae4933cd67a9b9103c4abf2cc93e784 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Mon, 22 Jul 2024 09:08:34 +0200 Subject: [PATCH] add neogit config and fix ebvious errors with keymaps --- init.lua | 2 +- lua/keymappings.lua | 3 + lua/plugins/init.lua | 5 + lua/plugins/neogit.lua | 300 +++++++++++++++++++++++++++++++++++++- lua/plugins/telescope.lua | 6 +- lua/settings.lua | 3 + lua/theme.lua | 2 +- 7 files changed, 314 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 195a73d..33bcdf8 100644 --- a/init.lua +++ b/init.lua @@ -4,6 +4,6 @@ vim.g.mapleader = ' ' -- Sensible defaults require('settings') require('plugins') -require('lsp') require('theme') +require('lsp') require('keymappings') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 9fe6679..23f0484 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -13,3 +13,6 @@ vim.keymap.set("n", "sq", "setlocal nospell") vim.keymap.set("n", "", "set nonumber!") vim.keymap.set("n", "fe", "Oil") + +vim.keymap.set("n", ']d', "lua vim.diagnostic.goto_next()") +vim.keymap.set("n", '[d', "lua vim.diagnostic.goto_prev()") diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 27b2b4f..9b2988e 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -81,6 +81,11 @@ require('packer').startup(function() -- Misc use { 'jbyuki/venn.nvim' } -- ascii diagrams use { 'hashivim/vim-terraform' } + + -- intellij idea to nvim o_O + use { 'Shougo/deoplete.nvim' } + use { 'beeender/Comrade' } + end) require('plugins.cmp') diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua index 605e648..9768e2b 100644 --- a/lua/plugins/neogit.lua +++ b/lua/plugins/neogit.lua @@ -1,5 +1,301 @@ local neogit = require('neogit') -neogit.setup {} - vim.keymap.set('n', '', neogit.open, {}) + +neogit.setup { + -- Hides the hints at the top of the status buffer + disable_hint = false, + -- Disables changing the buffer highlights based on where the cursor is. + disable_context_highlighting = false, + -- Disables signs for sections/items/hunks + disable_signs = false, + -- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to + -- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in + -- normal mode. + disable_insert_on_commit = "auto", + -- When enabled, will watch the `.git/` directory for changes and refresh the status buffer in response to filesystem + -- events. + filewatcher = { + interval = 1000, + enabled = true, + }, + -- "ascii" is the graph the git CLI generates + -- "unicode" is the graph like https://github.com/rbong/vim-flog + graph_style = "ascii", + -- Used to generate URL's for branch popup action "pull request". + git_services = { + ["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1", + ["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1", + ["gitlab.com"] = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}", + }, + -- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf + -- sorter instead. By default, this function returns `nil`. + telescope_sorter = function() + return require("telescope").extensions.fzf.native_fzf_sorter() + end, + -- Persist the values of switches/options within and across sessions + remember_settings = true, + -- Scope persisted settings on a per-project basis + use_per_project_settings = true, + -- Table of settings to never persist. Uses format "Filetype--cli-value" + ignored_settings = { + "NeogitPushPopup--force-with-lease", + "NeogitPushPopup--force", + "NeogitPullPopup--rebase", + "NeogitCommitPopup--allow-empty", + "NeogitRevertPopup--no-edit", + }, + -- Configure highlight group features + highlight = { + italic = true, + bold = true, + underline = true + }, + -- Set to false if you want to be responsible for creating _ALL_ keymappings + use_default_keymaps = true, + -- Neogit refreshes its internal state after specific events, which can be expensive depending on the repository size. + -- Disabling `auto_refresh` will make it so you have to manually refresh the status after you open it. + auto_refresh = true, + -- Value used for `--sort` option for `git branch` command + -- By default, branches will be sorted by commit date descending + -- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt + -- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options + sort_branches = "-committerdate", + -- Change the default way of opening neogit + kind = "tab", + -- Disable line numbers and relative line numbers + disable_line_numbers = true, + -- The time after which an output console is shown for slow running commands + console_timeout = 2000, + -- Automatically show console if a command takes more than console_timeout milliseconds + auto_show_console = true, + -- Automatically close the console if the process exits with a 0 (success) status + auto_close_console = true, + status = { + show_head_commit_hash = true, + recent_commit_count = 10, + HEAD_padding = 10, + HEAD_folded = false, + mode_padding = 3, + mode_text = { + M = "modified", + N = "new file", + A = "added", + D = "deleted", + C = "copied", + U = "updated", + R = "renamed", + DD = "unmerged", + AU = "unmerged", + UD = "unmerged", + UA = "unmerged", + DU = "unmerged", + AA = "unmerged", + UU = "unmerged", + ["?"] = "", + }, + }, + commit_editor = { + kind = "tab", + show_staged_diff = true, + -- Accepted values: + -- "split" to show the staged diff below the commit editor + -- "vsplit" to show it to the right + -- "split_above" Like :top split + -- "vsplit_left" like :vsplit, but open to the left + -- "auto" "vsplit" if window would have 80 cols, otherwise "split" + staged_diff_split_kind = "split" + }, + commit_select_view = { + kind = "tab", + }, + commit_view = { + kind = "vsplit", + verify_commit = vim.fn.executable("gpg") == 1, -- Can be set to true or false, otherwise we try to find the binary + }, + log_view = { + kind = "tab", + }, + rebase_editor = { + kind = "auto", + }, + reflog_view = { + kind = "tab", + }, + merge_editor = { + kind = "auto", + }, + tag_editor = { + kind = "auto", + }, + preview_buffer = { + kind = "split", + }, + popup = { + kind = "split", + }, + signs = { + -- { CLOSED, OPENED } + hunk = { "", "" }, + item = { ">", "v" }, + section = { ">", "v" }, + }, + -- Each Integration is auto-detected through plugin presence, however, it can be disabled by setting to `false` + integrations = { + -- If enabled, use telescope for menu selection rather than vim.ui.select. + -- Allows multi-select and some things that vim.ui.select doesn't. + telescope = nil, + -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `diffview`. + -- The diffview integration enables the diff popup. + -- + -- Requires you to have `sindrets/diffview.nvim` installed. + diffview = nil, + + -- If enabled, uses fzf-lua for menu selection. If the telescope integration + -- is also selected then telescope is used instead + -- Requires you to have `ibhagwan/fzf-lua` installed. + fzf_lua = nil, + }, + sections = { + -- Reverting/Cherry Picking + sequencer = { + folded = false, + hidden = false, + }, + untracked = { + folded = false, + hidden = false, + }, + unstaged = { + folded = false, + hidden = false, + }, + staged = { + folded = false, + hidden = false, + }, + stashes = { + folded = true, + hidden = false, + }, + unpulled_upstream = { + folded = true, + hidden = false, + }, + unmerged_upstream = { + folded = false, + hidden = false, + }, + unpulled_pushRemote = { + folded = true, + hidden = false, + }, + unmerged_pushRemote = { + folded = false, + hidden = false, + }, + recent = { + folded = true, + hidden = false, + }, + rebase = { + folded = true, + hidden = false, + }, + }, + mappings = { + commit_editor = { + ["q"] = "Close", + [""] = "Submit", + [""] = "Abort", + }, + commit_editor_I = { + [""] = "Submit", + [""] = "Abort", + }, + rebase_editor = { + ["p"] = "Pick", + ["r"] = "Reword", + ["e"] = "Edit", + ["s"] = "Squash", + ["f"] = "Fixup", + ["x"] = "Execute", + ["d"] = "Drop", + ["b"] = "Break", + ["q"] = "Close", + [""] = "OpenCommit", + ["gk"] = "MoveUp", + ["gj"] = "MoveDown", + [""] = "Submit", + [""] = "Abort", + ["[c"] = "OpenOrScrollUp", + ["]c"] = "OpenOrScrollDown", + }, + rebase_editor_I = { + [""] = "Submit", + [""] = "Abort", + }, + finder = { + [""] = "Select", + [""] = "Close", + [""] = "Close", + [""] = "Next", + [""] = "Previous", + [""] = "Next", + [""] = "Previous", + [""] = "MultiselectToggleNext", + [""] = "MultiselectTogglePrevious", + [""] = "NOP", + }, + -- Setting any of these to `false` will disable the mapping. + popup = { + ["?"] = "HelpPopup", + ["A"] = "CherryPickPopup", + ["D"] = "DiffPopup", + ["M"] = "RemotePopup", + ["P"] = "PushPopup", + ["X"] = "ResetPopup", + ["Z"] = "StashPopup", + ["b"] = "BranchPopup", + ["B"] = "BisectPopup", + ["c"] = "CommitPopup", + ["f"] = "FetchPopup", + ["l"] = "LogPopup", + ["m"] = "MergePopup", + ["p"] = "PullPopup", + ["r"] = "RebasePopup", + ["v"] = "RevertPopup", + ["w"] = "WorktreePopup", + }, + status = { + ["k"] = "MoveUp", + ["j"] = "MoveDown", + ["q"] = "Close", + ["o"] = "OpenTree", + ["I"] = "InitRepo", + ["1"] = "Depth1", + ["2"] = "Depth2", + ["3"] = "Depth3", + ["4"] = "Depth4", + [""] = "Toggle", + ["x"] = "Discard", + ["s"] = "Stage", + ["S"] = "StageUnstaged", + [""] = "StageAll", + ["K"] = "Untrack", + ["u"] = "Unstage", + ["U"] = "UnstageStaged", + ["$"] = "CommandHistory", + ["Y"] = "YankSelected", + [""] = "RefreshBuffer", + [""] = "GoToFile", + [""] = "VSplitOpen", + [""] = "SplitOpen", + [""] = "TabOpen", + ["{"] = "GoToPreviousHunkHeader", + ["}"] = "GoToNextHunkHeader", + ["[c"] = "OpenOrScrollUp", + ["]c"] = "OpenOrScrollDown", + }, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index e438d35..9c297c7 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -23,13 +23,13 @@ telescope.setup { vim.keymap.set('n', 'ss', telescope.extensions.luasnip.luasnip, {}) vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'ffg', builtin.git_files, {}) -vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fg', builtin.git_files, {}) +vim.keymap.set('n', 'gg', builtin.live_grep, {}) vim.keymap.set('n', 'fb', builtin.buffers, {}) vim.keymap.set('n', 'fs', builtin.lsp_dynamic_workspace_symbols, {}) vim.keymap.set('n', 'fsd', builtin.lsp_document_symbols, {}) vim.keymap.set('n', 'fh', builtin.help_tags, {}) -vim.keymap.set('n', 'fd', builtin.diagnostics, {}) +vim.keymap.set('n', 'dd', builtin.diagnostics, {}) -- Use telescope for lsp definitions, calls and references vim.keymap.set('n', 'gd', builtin.lsp_definitions, {}) diff --git a/lua/settings.lua b/lua/settings.lua index f54617c..3101d37 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -22,6 +22,7 @@ utils.opt('o', 'splitright', true) utils.opt('o', 'wildmode', 'list:longest') utils.opt('w', 'number', true) utils.opt('o', 'clipboard', 'unnamed,unnamedplus') +utils.opt('o', 'mouse', 'a') vim.opt.autoindent = false vim.opt.smartindent = false @@ -37,5 +38,7 @@ vim.opt.secure = true -- unknown filetypes mappings vim.cmd([[ autocmd BufRead,BufNewFile *.bu set filetype=yaml + autocmd BufRead,BufNewFile *.yml.example set filetype=yaml + autocmd BufRead,BufNewFile *.yaml.example set filetype=yaml autocmd BufRead,BufNewFile *.ign set filetype=json ]]) diff --git a/lua/theme.lua b/lua/theme.lua index 9151c72..77360ef 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,5 +1,5 @@ -- Revert to vim's default term colorscheme -vim.cmd 'colorscheme vim' +--vim.cmd 'colorscheme vim' vim.cmd 'set notermguicolors' -- Highlight trailing whitespace (darker red)