From c1b71e559fac733c5ec95ca5416f913b032696c3 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Mon, 20 Sep 2021 02:48:09 -0700 Subject: [PATCH] nvim: added smooth scrolling and fixed toggleterm --- .config/nvim/init.lua | 4 ++-- .config/nvim/lua/other.lua | 39 +++++++++++++++++++++++++---------- .config/nvim/lua/plugins.lua | 18 +++++----------- .config/nvim/lua/settings.lua | 2 ++ 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 2b9eda8..e3a483d 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -11,8 +11,8 @@ require('plugins') -- [x] map A-S to toggle spell check (see logic from hlsearch section in init.vim) -- -- Plugins to Configure --- [ ] toggleterm --- [ ] neoscroll +-- [x] toggleterm +-- [x] neoscroll -- [x] cmp -- [x] lspkind -- [x] lspsignature diff --git a/.config/nvim/lua/other.lua b/.config/nvim/lua/other.lua index 34e7939..0a9e5a0 100644 --- a/.config/nvim/lua/other.lua +++ b/.config/nvim/lua/other.lua @@ -44,15 +44,14 @@ end -- <<< M.toggleterm = function() require("toggleterm").setup{ -- size can be a number or function which is passed the current terminal - -- size = 20 | function(term) - -- if term.direction == "horizontal" then - -- return 15 - -- elseif term.direction == "vertical" then - -- return vim.o.columns * 0.4 - -- end - -- end, + size = function(term) + if term.direction == "horizontal" then + return 15 + elseif term.direction == "vertical" then + return vim.o.columns * 0.4 + end + end, open_mapping = [[]], - toggleterm_terminal_mapping = 't', hide_numbers = true, -- hide the number column in toggleterm buffers shade_filetypes = {}, shade_terminals = true, @@ -60,7 +59,7 @@ M.toggleterm = function() start_in_insert = true, insert_mappings = true, -- whether or not the open mapping applies in insert mode persist_size = true, - direction = 'vertical', -- | 'horizontal' | 'window' | 'float', + direction = 'float', -- vertical, horizontal, window, or float close_on_exit = true, -- close the terminal window when the process exits -- shell = vim.o.shell, -- change the default shell -- This field is only relevant if direction is set to 'float' @@ -69,10 +68,10 @@ M.toggleterm = function() -- see :h nvim_open_win for details on borders however -- the 'curved' border is a custom border type -- not natively supported but implemented in this plugin. - border = 'single', + border = 'curved', -- single, double, shadow, or curved width = 120, height = 32, - winblend = 3, + winblend = 10, -- transparancy highlights = { border = "Normal", background = "Normal", @@ -152,6 +151,24 @@ M.gitsigns = function() } end -- <<< +-- neoscroll for smooth scrolling >>> +M.neoscroll = function() + require('neoscroll').setup({ + -- All these keys will be mapped to their corresponding default scrolling animation + mappings = {'', '', '', '', + '', '', 'zt', 'zz', 'zb',}, + hide_cursor = true, -- Hide cursor while scrolling + stop_eof = true, -- Stop at when scrolling downwards + use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope + respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file + cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further + easing_function = 'sine', -- use sine easing function + pre_hook = nil, -- Function to run before the scrolling animation starts + post_hook = nil, -- Function to run after the scrolling animation ends + }) +end +-- <<< + -- Autosession >>> M.autosession = function() local opts = { diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 970edd1..2b39536 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -73,10 +73,7 @@ return require('packer').startup(function() require('lsp').cmp() end, requires = { -- nvim-cmp sources - -- snippet integration - -- "hrsh7th/cmp-vsnip", - "saadparwaiz1/cmp_luasnip", - + "saadparwaiz1/cmp_luasnip", --luasnip integration "hrsh7th/cmp-path", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", @@ -138,14 +135,9 @@ return require('packer').startup(function() } use { -- Smooth Scrolling "karb94/neoscroll.nvim", - -- disable = not plugin_status.neoscroll, - -- opt = true, - -- config = function() - -- require("plugins.configs.others").neoscroll() - -- end, - -- setup = function() - -- require("core.utils").packer_lazy_load "neoscroll.nvim" - -- end, + config = function() + require('other').neoscroll() + end, } use { -- automatic session management 'rmagatti/auto-session', @@ -153,7 +145,7 @@ return require('packer').startup(function() require('other').autosession() end } - use { + use { -- markdown preview 'ellisonleao/glow.nvim', ft = { 'md', 'markdown', } } diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index ae9c57f..e787f58 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -23,6 +23,8 @@ vim.cmd [[ syntax on set redrawtime=1000 " max syntax highlight time set number relativenumber + autocmd InsertEnter * :set norelativenumber " Automatically toggle line numbers + autocmd InsertLeave * :set relativenumber set noerrorbells set encoding=UTF-8 set cursorline