From f6ab0425f93edf5c5103dc029ed7dd81dd151bbb Mon Sep 17 00:00:00 2001 From: Ben Kyd Date: Tue, 31 Jan 2023 00:21:21 +0000 Subject: [PATCH] add smartsplits but idk how it works lol --- home/.config/nvim/README.md | 87 +++++++++++++++++++ .../.config/nvim/lua/plugin-config/barbar.lua | 5 ++ .../nvim/lua/plugin-config/codewindow.lua | 17 ++++ .../nvim/lua/plugin-config/smart-splits.lua | 62 +++++++++++++ home/.config/nvim/lua/plugins.lua | 4 + home/.config/nvim/plugin/packer_compiled.lua | 13 ++- 6 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 home/.config/nvim/README.md create mode 100644 home/.config/nvim/lua/plugin-config/barbar.lua create mode 100644 home/.config/nvim/lua/plugin-config/codewindow.lua create mode 100644 home/.config/nvim/lua/plugin-config/smart-splits.lua diff --git a/home/.config/nvim/README.md b/home/.config/nvim/README.md new file mode 100644 index 0000000..1a04f7f --- /dev/null +++ b/home/.config/nvim/README.md @@ -0,0 +1,87 @@ +# Short Intro + +![Screenshot](./assets/nvim-screenshot.png) + +This is my NeoVim config (for version 0.7.2 and greater). + +## Features + +Here's a short list of features that this config offers (through the use of 3rd party plugins). + +* Autocompletion +* Highlighting +* Navigation + * Find definition/declaration/implementation... + * Find all references (of variables, methods, classes...) + * Jump cursor focus forward/backward in time + * Project tree view (NvimTree) + * Switch between tabs +* Searching + * Search by file name + * Search by file contents + * Search through NeoVim's help +* Refactoring (code actions) + * Rename (variable, method, class...) + * Automatically import + * Simplify code + * Infer type info +* Diagnostics + * Show errors/warnings/hints/info + * Diagnostic panel + * Integration with status line +* Git + * Highlight edited lines in number column + * Navigate between hunks (changes) + * Stage/unstage hunks + * Preview old code + * Status line integration +* Misc + * Special start page + * Indent guide lines + * Motions for surrounding characters (brackets, parentheses...) + * Easy commenting out code + * Pretty status line + * Default colorscheme + * Enabled mouse integration + * Keymappings for 10 finger typing on Slovene keyboard + +## Installation + +I will make the whole installation process more friendly in the future, +but for now just follow these steps. + +1. Download this repo +```bash +git clone git@github.com:optimizacija/neovim-config.git +``` +2. Put the contents of this repo where NeoVim can find them. On Linux this is most likely `$HOME/.config/nvim`. +3. Create a *data* folder. This is where NeoVim will search for its packages, including Packer. + - On Linux this is `$HOME/.local/share/nvim`. Otherwise check the output of `:lua print(vim.fn.stdpath('data'))`. +4. Open NeoVim and let it install Packer and all the dependencies (ignore the errors). +5. Open NeoVim again and wait for nvim-treesitter to install all of its dependencies (ignore the errors). + +If you're updating an existing config and you're facing some issues, +I would recommend that you remove the contents of *data* folder and retry the installation. (It has helped me in the past) + + +## Icons +Icons and other special characters are used all around the config to give NeoVim a prettier look. +However, your terminal will not display these icons correctly unless it uses the correct font. + +Install one of the icon fonts listed [here](https://www.nerdfonts.com/). Just follow their instructions for your specific OS. +After installation is complete, don't forget to configure your terminal to start using the new font. +Each terminal does this differently, so be sure to checkout [Arch Wiki](https://wiki.archlinux.org/) if you run into any troubles. + + +## TODOS + +I'm working on this config in my spare time, but lately other side projects are getting in the way. I'll try to update it when I can, but also feel free to contribute by submitting a PR with your changes. + +Minor: +- improve telescope functionality (support regex) + +Major: +- autoformat (prettier) + +Misc: +- open previously opened project files diff --git a/home/.config/nvim/lua/plugin-config/barbar.lua b/home/.config/nvim/lua/plugin-config/barbar.lua new file mode 100644 index 0000000..95cf494 --- /dev/null +++ b/home/.config/nvim/lua/plugin-config/barbar.lua @@ -0,0 +1,5 @@ +-- tab movement +local opts = {noremap = true, silent = true} +vim.api.nvim_set_keymap('', 'J', 'BufferPrevious', opts) +vim.api.nvim_set_keymap('', 'Č', 'BufferNext', opts) +vim.api.nvim_set_keymap('', 'X', 'BufferClose', opts) diff --git a/home/.config/nvim/lua/plugin-config/codewindow.lua b/home/.config/nvim/lua/plugin-config/codewindow.lua new file mode 100644 index 0000000..012e834 --- /dev/null +++ b/home/.config/nvim/lua/plugin-config/codewindow.lua @@ -0,0 +1,17 @@ +local codewindow = require('codewindow') +codewindow.setup { + active_in_terminals = false, -- Should the minimap activate for terminal buffers + auto_enable = false, -- Automatically open the minimap when entering a (non-excluded) buffer (accepts a table of filetypes) + exclude_filetypes = { "NvimTree" }, -- Choose certain filetypes to not show minimap on + max_minimap_height = nil, -- The maximum height the minimap can take (including borders) + max_lines = nil, -- If auto_enable is true, don't open the minimap for buffers which have more than this many lines. + minimap_width = 20, -- The width of the text part of the minimap + use_lsp = true, -- Use the builtin LSP to show errors and warnings + use_treesitter = true, -- Use nvim-treesitter to highlight the code + use_git = true, -- Show small dots to indicate git additions and deletions + width_multiplier = 2, -- How many characters one dot represents + z_index = 1, -- The z-index the floating window will be on + show_cursor = true, -- Show the cursor position in the minimap + window_border = 'single' -- The border style of the floating window (accepts all usual options) +} +codewindow.apply_default_keybinds() diff --git a/home/.config/nvim/lua/plugin-config/smart-splits.lua b/home/.config/nvim/lua/plugin-config/smart-splits.lua new file mode 100644 index 0000000..64c7436 --- /dev/null +++ b/home/.config/nvim/lua/plugin-config/smart-splits.lua @@ -0,0 +1,62 @@ +require('smart-splits').setup({ + -- Ignored filetypes (only while resizing) + ignored_filetypes = { + 'nofile', + 'quickfix', + 'prompt', + }, + -- Ignored buffer types (only while resizing) + ignored_buftypes = { 'NvimTree' }, + -- the default number of lines/columns to resize by at a time + default_amount = 3, + -- whether to wrap to opposite side when cursor is at an edge + -- e.g. by default, moving left at the left edge will jump + -- to the rightmost window, and vice versa, same for up/down. + wrap_at_edge = true, + -- when moving cursor between splits left or right, + -- place the cursor on the same row of the *screen* + -- regardless of line numbers. False by default. + -- Can be overridden via function parameter, see Usage. + move_cursor_same_row = false, + -- resize mode options + resize_mode = { + -- key to exit persistent resize mode + quit_key = '', + -- keys to use for moving in resize mode + -- in order of left, down, up' right + resize_keys = { 'Left', 'Down', 'Up', 'Right' }, + -- set to true to silence the notifications + -- when entering/exiting persistent resize mode + silent = false, + -- must be functions, they will be executed when + -- entering or exiting the resize mode + hooks = { + on_enter = nil, + on_leave = nil, + }, + }, + -- ignore these autocmd events (via :h eventignore) while processing + -- smart-splits.nvim computations, which involve visiting different + -- buffers and windows. These events will be ignored during processing, + -- and un-ignored on completed. This only applies to resize events, + -- not cursor movement events. + ignored_events = { + 'BufEnter', + 'WinEnter', + }, + -- enable or disable the tmux integration + tmux_integration = true, + -- disable tmux navigation if current tmux pane is zoomed + disable_tmux_nav_when_zoomed = true, +}) + +vim.keymap.set('n', '', require('smart-splits').resize_left) +vim.keymap.set('n', '', require('smart-splits').resize_down) +vim.keymap.set('n', '', require('smart-splits').resize_up) +vim.keymap.set('n', '', require('smart-splits').resize_right) +-- moving between splits +vim.keymap.set('n', '', require('smart-splits').move_cursor_left) +vim.keymap.set('n', '', require('smart-splits').move_cursor_down) +vim.keymap.set('n', '', require('smart-splits').move_cursor_up) +vim.keymap.set('n', '', require('smart-splits').move_cursor_right) + diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 745002b..ed624d5 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -37,6 +37,9 @@ local packer = require('packer').startup(function(use) -- better highlighting use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'} + -- better split navigation + use 'mrjones2014/smart-splits.nvim' + -- gorbit's codewindow use { 'gorbit99/codewindow.nvim', @@ -157,5 +160,6 @@ require('plugin-config/indent-guide-lines') require('plugin-config/dressing') require('plugin-config/noice') require('plugin-config/ministarter') +require('plugin-config/smart-splits') return packer diff --git a/home/.config/nvim/plugin/packer_compiled.lua b/home/.config/nvim/plugin/packer_compiled.lua index 0dbeb75..56f2657 100644 --- a/home/.config/nvim/plugin/packer_compiled.lua +++ b/home/.config/nvim/plugin/packer_compiled.lua @@ -226,6 +226,11 @@ _G.packer_plugins = { path = "/home/ben/.local/share/nvim/site/pack/packer/start/plenary.nvim", url = "https://github.com/nvim-lua/plenary.nvim" }, + ["smart-splits.nvim"] = { + loaded = true, + path = "/home/ben/.local/share/nvim/site/pack/packer/start/smart-splits.nvim", + url = "https://github.com/mrjones2014/smart-splits.nvim" + }, ["telescope.nvim"] = { loaded = true, path = "/home/ben/.local/share/nvim/site/pack/packer/start/telescope.nvim", @@ -254,14 +259,14 @@ _G.packer_plugins = { } time([[Defining packer_plugins]], false) --- Config for: codewindow.nvim -time([[Config for codewindow.nvim]], true) -try_loadstring("\27LJ\2\nW\0\0\3\0\4\0\b6\0\0\0'\2\1\0B\0\2\0029\1\2\0B\1\1\0019\1\3\0B\1\1\1K\0\1\0\27apply_default_keybinds\nsetup\15codewindow\frequire\0", "config", "codewindow.nvim") -time([[Config for codewindow.nvim]], false) -- Config for: lspsaga.nvim time([[Config for lspsaga.nvim]], true) try_loadstring("\27LJ\2\n9\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\flspsaga\frequire\0", "config", "lspsaga.nvim") time([[Config for lspsaga.nvim]], false) +-- Config for: codewindow.nvim +time([[Config for codewindow.nvim]], true) +try_loadstring("\27LJ\2\nW\0\0\3\0\4\0\b6\0\0\0'\2\1\0B\0\2\0029\1\2\0B\1\1\0019\1\3\0B\1\1\1K\0\1\0\27apply_default_keybinds\nsetup\15codewindow\frequire\0", "config", "codewindow.nvim") +time([[Config for codewindow.nvim]], false) _G._packer.inside_compile = false if _G._packer.needs_bufread == true then