aboutsummaryrefslogtreecommitdiff
path: root/Common/nvim
diff options
context:
space:
mode:
authorjakob.stendahl <jakob.stendahl@infomedia.dk>2023-01-11 12:20:00 +0100
committerjakob.stendahl <jakob.stendahl@infomedia.dk>2023-01-11 12:20:00 +0100
commit763df8e9d428422d7db6fe157dd8f14656aba6e2 (patch)
tree987e8f41252a4caf67802598d172ebfcc8de0a4c /Common/nvim
parent2c9ca86b6a834e1be66678eee78246f8339b3e73 (diff)
downloaddotfiles-763df8e9d428422d7db6fe157dd8f14656aba6e2.tar.gz
dotfiles-763df8e9d428422d7db6fe157dd8f14656aba6e2.zip
Add some convenience functions
Diffstat (limited to 'Common/nvim')
-rwxr-xr-xCommon/nvim/lua/helper_functions.lua20
-rwxr-xr-xCommon/nvim/lua/plugins.lua9
2 files changed, 29 insertions, 0 deletions
diff --git a/Common/nvim/lua/helper_functions.lua b/Common/nvim/lua/helper_functions.lua
index cac6c00..715c2a7 100755
--- a/Common/nvim/lua/helper_functions.lua
+++ b/Common/nvim/lua/helper_functions.lua
@@ -21,6 +21,26 @@ function ToggleListChars()
vim.opt.listchars = list_chars_enabled and list_chars_when_enabled or 'eol:$'
end
+-- Command to join lines in buffer as list
+function JoinLines(args, quotes)
+ r = args.args
+ o = ""
+ for k, v in pairs(vim.fn.getreg(r, 1, 1)) do
+ if k > 1 then o = o .. ", " end
+ if quotes ~= nil then o = o .. quotes end
+ o = o .. v:match( "^%s*(.-)%s*$" ) -- Strip leading and trailing
+ if quotes ~= nil then o = o .. quotes end
+ end
+ vim.fn.setreg(r, o)
+end
+function JoinLinesSQ(args) JoinLines(args, "'") end
+function JoinLinesDQ(args) JoinLines(args, '"') end
+function JoinLinesBT(args) JoinLines(args, "`") end
+vim.api.nvim_create_user_command('JoinLines', JoinLines, {bang=false, desc='Joins all lines in a register', nargs='?'})
+vim.api.nvim_create_user_command('JoinLinesSQ', JoinLinesSQ, {bang=false, desc='Joins all lines in a register', nargs='?'})
+vim.api.nvim_create_user_command('JoinLinesDQ', JoinLinesDQ, {bang=false, desc='Joins all lines in a register', nargs='?'})
+vim.api.nvim_create_user_command('JoinLinesBT', JoinLinesBT, {bang=false, desc='Joins all lines in a register', nargs='?'})
+
-- Close buffer without closing window
--[[
vim.cmd [[
diff --git a/Common/nvim/lua/plugins.lua b/Common/nvim/lua/plugins.lua
index 555dad3..3077560 100755
--- a/Common/nvim/lua/plugins.lua
+++ b/Common/nvim/lua/plugins.lua
@@ -16,6 +16,8 @@ vim.cmd([[
return require('packer').startup(function(use)
-- Packer itself :)
use 'wbthomason/packer.nvim'
+ -- targets (extends vim's targets, allowing things like multiline select inside backticks)
+ use 'wellle/targets.vim';
-- GitSigns
use {
@@ -160,6 +162,13 @@ return require('packer').startup(function(use)
use 'mfussenegger/nvim-jdtls'
+ -- Goyo :)
+ use {
+ 'junegunn/goyo.vim'
+ }
+ use { 'smithbm2316/centerpad.nvim' }
+
+ -- packer.nvim
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then