diff --git a/ftplugin/html.lua b/ftplugin/html.lua
index d0bac89..319e2e5 100644
--- a/ftplugin/html.lua
+++ b/ftplugin/html.lua
@@ -1,2 +1 @@
-vim.bo.shiftwidth = 2
-vim.bo.tabstop = 2
+require("helpers").set_tab(2)
diff --git a/ftplugin/htmldjango.lua b/ftplugin/htmldjango.lua
index d0bac89..319e2e5 100644
--- a/ftplugin/htmldjango.lua
+++ b/ftplugin/htmldjango.lua
@@ -1,2 +1 @@
-vim.bo.shiftwidth = 2
-vim.bo.tabstop = 2
+require("helpers").set_tab(2)
diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua
index b3bc028..319e2e5 100644
--- a/ftplugin/javascript.lua
+++ b/ftplugin/javascript.lua
@@ -1,3 +1 @@
-local len = 2
-vim.bo.shiftwidth = len
-vim.bo.tabstop = len
+require("helpers").set_tab(2)
diff --git a/ftplugin/javascriptreact.lua b/ftplugin/javascriptreact.lua
index b3bc028..319e2e5 100644
--- a/ftplugin/javascriptreact.lua
+++ b/ftplugin/javascriptreact.lua
@@ -1,3 +1 @@
-local len = 2
-vim.bo.shiftwidth = len
-vim.bo.tabstop = len
+require("helpers").set_tab(2)
diff --git a/ftplugin/json.lua b/ftplugin/json.lua
index b3bc028..319e2e5 100644
--- a/ftplugin/json.lua
+++ b/ftplugin/json.lua
@@ -1,3 +1 @@
-local len = 2
-vim.bo.shiftwidth = len
-vim.bo.tabstop = len
+require("helpers").set_tab(2)
diff --git a/ftplugin/svelte.lua b/ftplugin/svelte.lua
index b3bc028..319e2e5 100644
--- a/ftplugin/svelte.lua
+++ b/ftplugin/svelte.lua
@@ -1,3 +1 @@
-local len = 2
-vim.bo.shiftwidth = len
-vim.bo.tabstop = len
+require("helpers").set_tab(2)
diff --git a/ftplugin/text.lua b/ftplugin/text.lua
index 1ca5e12..23bd033 100644
--- a/ftplugin/text.lua
+++ b/ftplugin/text.lua
@@ -1,13 +1,7 @@
-local function local_map(mode, lhs, rhs, opts)
- local options = { noremap = true }
- if opts then
- options = vim.tbl_extend("force", options, opts)
- end
- vim.api.nvim_buf_set_keymap(0, mode, lhs, rhs, options)
-end
+local map = require("helpers").map
local function silent_map(mode, lhs, rhs)
- local_map(mode, lhs, rhs, { silent = true })
+ map(mode, lhs, rhs, { silent = true })
end
silent_map("n", "", "gk")
diff --git a/ftplugin/typescript.lua b/ftplugin/typescript.lua
index b3bc028..319e2e5 100644
--- a/ftplugin/typescript.lua
+++ b/ftplugin/typescript.lua
@@ -1,3 +1 @@
-local len = 2
-vim.bo.shiftwidth = len
-vim.bo.tabstop = len
+require("helpers").set_tab(2)
diff --git a/ftplugin/typescriptreact.lua b/ftplugin/typescriptreact.lua
index b3bc028..319e2e5 100644
--- a/ftplugin/typescriptreact.lua
+++ b/ftplugin/typescriptreact.lua
@@ -1,3 +1 @@
-local len = 2
-vim.bo.shiftwidth = len
-vim.bo.tabstop = len
+require("helpers").set_tab(2)
diff --git a/ftplugin/vue.lua b/ftplugin/vue.lua
index b3bc028..319e2e5 100644
--- a/ftplugin/vue.lua
+++ b/ftplugin/vue.lua
@@ -1,3 +1 @@
-local len = 2
-vim.bo.shiftwidth = len
-vim.bo.tabstop = len
+require("helpers").set_tab(2)
diff --git a/ftplugin/yaml.lua.nothanks b/ftplugin/yaml.lua.nothanks
index bcf38c1..57e3c47 100644
--- a/ftplugin/yaml.lua.nothanks
+++ b/ftplugin/yaml.lua.nothanks
@@ -1,2 +1 @@
-vim.bo.shiftwidth = 4
-vim.bo.tabstop = 4
+require("helpers").set_tab(4)
diff --git a/init.lua b/init.lua
index 51c205c..98e9e2b 100644
--- a/init.lua
+++ b/init.lua
@@ -1,3 +1,2 @@
-require("packer_check")
require("base")
require("plugins")
diff --git a/lua/base.lua b/lua/base.lua
index 1b0af9f..b912e54 100644
--- a/lua/base.lua
+++ b/lua/base.lua
@@ -1,9 +1,7 @@
-- SHOULD NOT CONTAIN ANY SETTINGS RELATED TO EXTERNAL PLUGINS
-- OR CUSTOM CODE YOU YOURSELF WROTE.
-local helpers = require("helpers")
-local map = helpers.map
-
+local map = require("helpers").map
local opt = vim.opt
local g = vim.g
@@ -53,6 +51,20 @@ map("t", "", [[]])
map("n", [[\]], ":" .. term_command .. "")
map("n", [[|]], ":v" .. term_command .. "")
+-- Move cursor relative to visual line breaks
+local function silent_map(mode, lhs, rhs)
+ map(mode, lhs, rhs, { silent = true })
+end
+
+silent_map("n", "", "gk")
+silent_map("n", "", "gj")
+silent_map("n", "", "g")
+silent_map("n", "", "g")
+
+silent_map("i", "", "gk")
+silent_map("i", "", "gj")
+silent_map("i", "", "g")
+silent_map("i", "", "g")
opt.autoindent = true
opt.autoread = true
diff --git a/lua/helpers.lua b/lua/helpers.lua
index 75d69ca..c6dd720 100644
--- a/lua/helpers.lua
+++ b/lua/helpers.lua
@@ -71,4 +71,9 @@ function M.lsp_config_defaults()
}
end
+function M.set_tab(length)
+ vim.bo.shiftwidth = length
+ vim.bo.tabstop = length
+end
+
return M
diff --git a/lua/plugins/config.lua b/lua/plugins/config.lua
index ea72377..9910140 100644
--- a/lua/plugins/config.lua
+++ b/lua/plugins/config.lua
@@ -36,11 +36,15 @@ function M.fzf()
map("n", "r", ":Rg ")
map("n", "R", ":Rg")
map("n", "s", ":Lines")
- map("n", "gf", ":GFiles")
- map("n", "gn", ":GFiles?")
+ map("n", "gl", ":GFiles")
+ map("n", "gs", ":GFiles?")
map("n", "gc", ":Commits")
end
+function M.fzf_checkout()
+ map("n", "gb", ":GBranches")
+end
+
function M.rnvimr()
map("n", "f", [[:RnvimrToggle]])
end
@@ -72,10 +76,6 @@ function M.auto_session()
})
end
-function M.fzf_checkout()
- map("n", "gb", ":GBranches")
-end
-
function M.indent_blankline()
vim.opt.list = true
diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua
index dc29da9..f7e575d 100644
--- a/lua/plugins/init.lua
+++ b/lua/plugins/init.lua
@@ -1,3 +1,4 @@
+require("plugins.install_packer")
require("plugins.startup")
local config = require("plugins.config")
diff --git a/lua/packer_check.lua b/lua/plugins/install_packer.lua
similarity index 100%
rename from lua/packer_check.lua
rename to lua/plugins/install_packer.lua