From dc1cbe850527fb4194b090a93773dfbe14b47e26 Mon Sep 17 00:00:00 2001 From: hologroove Date: Fri, 20 Dec 2024 15:17:58 +0100 Subject: [PATCH] First config attempt - some LazyVim style keymaps - Mason using local registry (erlang-ls v1.1.0 not yet merged to registry, after that it's not needed) - erlang-ls LSP - LazyGit plugin - Telescope file_browser plugin - enable Nerd fonts - listchars for leading space --- init.lua | 108 +++++++++++++++++++++++++++++---- lazyvim.json | 9 +++ lua/custom/plugins/lazygit.lua | 20 ++++++ 3 files changed, 125 insertions(+), 12 deletions(-) create mode 100644 lazyvim.json create mode 100644 lua/custom/plugins/lazygit.lua diff --git a/init.lua b/init.lua index ea86b792..6d3aaca1 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -146,7 +146,7 @@ vim.opt.splitbelow = true -- See `:help 'list'` -- and `:help 'listchars'` vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣', lead = '.' } -- Preview substitutions live, as you type! vim.opt.inccommand = 'split' @@ -189,14 +189,49 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the left wind vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- +-- Resize window using arrow keys +vim.keymap.set('n', '', 'resize +2', { desc = 'Increase Window Height' }) +vim.keymap.set('n', '', 'resize -2', { desc = 'Decrease Window Height' }) +vim.keymap.set('n', '', 'vertical resize -2', { desc = 'Decrease Window Width' }) +vim.keymap.set('n', '', 'vertical resize +2', { desc = 'Increase Window Width' }) --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` +-- Move Lines +vim.keymap.set('n', '', "execute 'move .+' . v:count1==", { desc = 'Move Down' }) +vim.keymap.set('n', '', "execute 'move .-' . (v:count1 + 1)==", { desc = 'Move Up' }) +vim.keymap.set('i', '', 'm .+1==gi', { desc = 'Move Down' }) +vim.keymap.set('i', '', 'm .-2==gi', { desc = 'Move Up' }) +vim.keymap.set('v', '', ":execute \"'<,'>move '>+\" . v:count1gv=gv", { desc = 'Move Down' }) +vim.keymap.set('v', '', ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { desc = 'Move Up' }) +-- +-- buffers +vim.keymap.set('n', '', 'bprevious', { desc = 'Prev Buffer' }) +vim.keymap.set('n', '', 'bnext', { desc = 'Next Buffer' }) +vim.keymap.set('n', '[b', 'bprevious', { desc = 'Prev Buffer' }) +vim.keymap.set('n', ']b', 'bnext', { desc = 'Next Buffer' }) +vim.keymap.set('n', 'bb', 'e #', { desc = 'Switch to Other Buffer' }) +--vim.keymap.set('n', '`', 'e #', { desc = 'Switch to Other Buffer' }) +vim.keymap.set('n', 'bd', 'bdelete', { desc = 'Delete Buffer' }) +-- +-- Add undo break-points +vim.keymap.set('i', ',', ',u') +vim.keymap.set('i', '.', '.u') +vim.keymap.set('i', ';', ';u') --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { +-- better indenting: stay in visual mode after indent +vim.keymap.set('v', '<', '', '>gv') + +-- save file +vim.keymap.set({ 'i', 'x', 'n', 's' }, '', 'w', { desc = 'save file' }) + +-- [[ basic autocommands ]] +-- see `:help lua-guide-autocommands` + +-- highlight when yanking (copying) text +-- try it with `yap` in normal mode +-- see `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('textyankpost', { desc = 'Highlight when yanking (copying) text', group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() @@ -332,6 +367,19 @@ require('lazy').setup({ -- -- Use the `dependencies` key to specify the dependencies of a particular plugin + { + 'nvim-telescope/telescope-file-browser.nvim', + dependencies = { 'nvim-telescope/telescope.nvim', 'nvim-lua/plenary.nvim' }, + -- keys = { + -- { + -- 'e', + -- ':Telescope file_browser path=%:p:h select_buffer=true follow_symlinks=true no_ignore=true', + -- desc = 'Browse current file', + -- }, + -- { 'e', 'e', desc = 'Browse Files', remap = true }, + -- }, + }, + { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', event = 'VimEnter', @@ -389,6 +437,20 @@ require('lazy').setup({ -- }, -- pickers = {} extensions = { + file_browser = { + -- theme = "ivy", + hijack_netrw = true, + -- mappings = { + -- ["i"] = { + -- -- your custom insert mode mappings + -- }, + -- ["n"] = { + -- -- your custom normal mode mappings + -- }, + -- }, + display_stat = false, + -- display_stat = { date = false, size = true, mode = false }, + }, ['ui-select'] = { require('telescope.themes').get_dropdown(), }, @@ -398,19 +460,29 @@ require('lazy').setup({ -- Enable Telescope extensions if they are installed pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') + pcall(require('telescope').load_extension, 'file_browser') -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + -- vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', '', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + -- vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', 'b', builtin.buffers, { desc = '[B] Find existing [B]uffers' }) + + vim.keymap.set( + 'n', + 'e', + ':Telescope file_browser path=%:p:h select_buffer=true follow_symlinks=true no_ignore=true', + { desc = '[S]earch File [E]ditor' } + ) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() @@ -632,6 +704,14 @@ require('lazy').setup({ }, }, }, + erlangls = { + -- cmd = { '/Users/lasiva/bin/erlang_ls' }, + root_dir = function(fname) + local root_pattern = require('lspconfig').util.root_pattern 'erlang_ls.config'(fname) + return root_pattern + end, + }, + sqlls = {}, } -- Ensure the servers and tools above are installed @@ -640,7 +720,11 @@ require('lazy').setup({ -- :Mason -- -- You can press `g?` for help in this menu. - require('mason').setup() + require('mason').setup { + registries = { + 'file:/Users/lasiva/Documents/priv/mason-registry', + }, + } -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. @@ -929,7 +1013,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lazyvim.json b/lazyvim.json new file mode 100644 index 00000000..82e173e1 --- /dev/null +++ b/lazyvim.json @@ -0,0 +1,9 @@ +{ + "extras": [ + + ], + "news": { + "NEWS.md": "10960" + }, + "version": 7 +} \ No newline at end of file diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000..501c674b --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,20 @@ +return { + 'kdheepak/lazygit.nvim', + lazy = true, + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { 'gg', 'LazyGitCurrentFile', desc = 'LazyGit' }, + }, +}