Add scroll
This commit is contained in:
		
							parent
							
								
									897b9691f9
								
							
						
					
					
						commit
						97dac44054
					
				|  | @ -13,6 +13,7 @@ | ||||||
|   "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, |   "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, | ||||||
|   "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, |   "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, | ||||||
|   "neodev.nvim": { "branch": "main", "commit": "029899ea32d3dc8ed8c910ceca2ee5d16e566c11" }, |   "neodev.nvim": { "branch": "main", "commit": "029899ea32d3dc8ed8c910ceca2ee5d16e566c11" }, | ||||||
|  |   "neoscroll.nvim": { "branch": "master", "commit": "be4ebf855a52f71ca4338694a5696675d807eff9" }, | ||||||
|   "nvim-blame-line": { "branch": "master", "commit": "b3d94f0ed5882d3d1c843c69788b9670476e1f42" }, |   "nvim-blame-line": { "branch": "master", "commit": "b3d94f0ed5882d3d1c843c69788b9670476e1f42" }, | ||||||
|   "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, |   "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, | ||||||
|   "nvim-lspconfig": { "branch": "master", "commit": "9099871a7c7e1c16122e00d70208a2cd02078d80" }, |   "nvim-lspconfig": { "branch": "master", "commit": "9099871a7c7e1c16122e00d70208a2cd02078d80" }, | ||||||
|  | @ -22,6 +23,7 @@ | ||||||
|   "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, |   "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, | ||||||
|   "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, |   "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, | ||||||
|   "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, |   "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, | ||||||
|  |   "typescript-tools.nvim": { "branch": "master", "commit": "829b5dc4f6704b249624e5157ad094dcb20cdc6b" }, | ||||||
|   "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, |   "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, | ||||||
|   "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, |   "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, | ||||||
|   "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, |   "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, | ||||||
|  |  | ||||||
|  | @ -0,0 +1,48 @@ | ||||||
|  | return { | ||||||
|  |   'karb94/neoscroll.nvim', | ||||||
|  |   config = function() | ||||||
|  |     local neoscroll = require("neoscroll") | ||||||
|  | 
 | ||||||
|  |     local easing = "sine" | ||||||
|  |     local zz_time_ms = 100 | ||||||
|  |     local jump_time_ms = 200 | ||||||
|  | 
 | ||||||
|  |     local centering_function = function() | ||||||
|  |       local defer_time_ms = 10 | ||||||
|  |       -- The `defer_fn` is a bit of a hack. | ||||||
|  |       -- We use it so that `neoscroll.init.scroll` will be false when we call `neoscroll.zz` | ||||||
|  |       -- As long as we don't input another neoscroll mapping in the timeout, | ||||||
|  |       -- we should be able to center the cursor. | ||||||
|  |       vim.defer_fn(function() | ||||||
|  |         neoscroll.zz(zz_time_ms, easing) | ||||||
|  |       end, defer_time_ms) | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|  |     neoscroll.setup({ | ||||||
|  |       pre_hook = function() | ||||||
|  |         vim.opt.eventignore:append({ | ||||||
|  |           'WinScrolled', | ||||||
|  |           'CursorMoved', | ||||||
|  |         }) | ||||||
|  |       end, | ||||||
|  |       post_hook = function(info) | ||||||
|  |         vim.opt.eventignore:remove({ | ||||||
|  |           'WinScrolled', | ||||||
|  |           'CursorMoved', | ||||||
|  |         }) | ||||||
|  |         if info ~= "center" then | ||||||
|  |           return | ||||||
|  |         end | ||||||
|  | 
 | ||||||
|  |         centering_function() | ||||||
|  |       end, | ||||||
|  |     }) | ||||||
|  | 
 | ||||||
|  |     local mappings = {} | ||||||
|  | 
 | ||||||
|  |     mappings["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", jump_time_ms, easing, "'center'" } } | ||||||
|  |     mappings["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", jump_time_ms, easing, "'center'" } } | ||||||
|  | 
 | ||||||
|  |     require("neoscroll.config").set_mappings(mappings) | ||||||
|  |   end, | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue