nvim: added smooth scrolling and fixed toggleterm

This commit is contained in:
PowerUser64 2021-09-20 02:48:09 -07:00
parent 2dcac10784
commit c1b71e559f
4 changed files with 37 additions and 26 deletions

View file

@ -11,8 +11,8 @@ require('plugins')
-- [x] map A-S to toggle spell check (see logic from hlsearch section in init.vim) -- [x] map A-S to toggle spell check (see logic from hlsearch section in init.vim)
-- --
-- Plugins to Configure -- Plugins to Configure
-- [ ] toggleterm -- [x] toggleterm
-- [ ] neoscroll -- [x] neoscroll
-- [x] cmp -- [x] cmp
-- [x] lspkind -- [x] lspkind
-- [x] lspsignature -- [x] lspsignature

View file

@ -44,15 +44,14 @@ end -- <<<
M.toggleterm = function() M.toggleterm = function()
require("toggleterm").setup{ require("toggleterm").setup{
-- size can be a number or function which is passed the current terminal -- size can be a number or function which is passed the current terminal
-- size = 20 | function(term) size = function(term)
-- if term.direction == "horizontal" then if term.direction == "horizontal" then
-- return 15 return 15
-- elseif term.direction == "vertical" then elseif term.direction == "vertical" then
-- return vim.o.columns * 0.4 return vim.o.columns * 0.4
-- end end
-- end, end,
open_mapping = [[<c-\>]], open_mapping = [[<c-\>]],
toggleterm_terminal_mapping = '<Leader>t',
hide_numbers = true, -- hide the number column in toggleterm buffers hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {}, shade_filetypes = {},
shade_terminals = true, shade_terminals = true,
@ -60,7 +59,7 @@ M.toggleterm = function()
start_in_insert = true, start_in_insert = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode insert_mappings = true, -- whether or not the open mapping applies in insert mode
persist_size = true, 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 close_on_exit = true, -- close the terminal window when the process exits
-- shell = vim.o.shell, -- change the default shell -- shell = vim.o.shell, -- change the default shell
-- This field is only relevant if direction is set to 'float' -- 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 -- see :h nvim_open_win for details on borders however
-- the 'curved' border is a custom border type -- the 'curved' border is a custom border type
-- not natively supported but implemented in this plugin. -- not natively supported but implemented in this plugin.
border = 'single', border = 'curved', -- single, double, shadow, or curved
width = 120, width = 120,
height = 32, height = 32,
winblend = 3, winblend = 10, -- transparancy
highlights = { highlights = {
border = "Normal", border = "Normal",
background = "Normal", background = "Normal",
@ -152,6 +151,24 @@ M.gitsigns = function()
} }
end -- <<< end -- <<<
-- neoscroll for smooth scrolling >>>
M.neoscroll = function()
require('neoscroll').setup({
-- All these keys will be mapped to their corresponding default scrolling animation
mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>',
'<C-y>', '<C-e>', 'zt', 'zz', 'zb',},
hide_cursor = true, -- Hide cursor while scrolling
stop_eof = true, -- Stop at <EOF> 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 >>> -- Autosession >>>
M.autosession = function() M.autosession = function()
local opts = { local opts = {

View file

@ -73,10 +73,7 @@ return require('packer').startup(function()
require('lsp').cmp() require('lsp').cmp()
end, end,
requires = { -- nvim-cmp sources requires = { -- nvim-cmp sources
-- snippet integration "saadparwaiz1/cmp_luasnip", --luasnip integration
-- "hrsh7th/cmp-vsnip",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
@ -138,14 +135,9 @@ return require('packer').startup(function()
} }
use { -- Smooth Scrolling use { -- Smooth Scrolling
"karb94/neoscroll.nvim", "karb94/neoscroll.nvim",
-- disable = not plugin_status.neoscroll, config = function()
-- opt = true, require('other').neoscroll()
-- config = function() end,
-- require("plugins.configs.others").neoscroll()
-- end,
-- setup = function()
-- require("core.utils").packer_lazy_load "neoscroll.nvim"
-- end,
} }
use { -- automatic session management use { -- automatic session management
'rmagatti/auto-session', 'rmagatti/auto-session',
@ -153,7 +145,7 @@ return require('packer').startup(function()
require('other').autosession() require('other').autosession()
end end
} }
use { use { -- markdown preview
'ellisonleao/glow.nvim', 'ellisonleao/glow.nvim',
ft = { 'md', 'markdown', } ft = { 'md', 'markdown', }
} }

View file

@ -23,6 +23,8 @@ vim.cmd [[
syntax on syntax on
set redrawtime=1000 " max syntax highlight time set redrawtime=1000 " max syntax highlight time
set number relativenumber set number relativenumber
autocmd InsertEnter * :set norelativenumber " Automatically toggle line numbers
autocmd InsertLeave * :set relativenumber
set noerrorbells set noerrorbells
set encoding=UTF-8 set encoding=UTF-8
set cursorline set cursorline