diff --git a/lua/taken/core/cmd.lua b/lua/taken/core/cmd.lua index 6983d40..63b7c99 100644 --- a/lua/taken/core/cmd.lua +++ b/lua/taken/core/cmd.lua @@ -7,7 +7,7 @@ local mkdirrun = augroup("MkdirRun", { clear = true }) local yank = augroup("kickstart-highlight-yank", { clear = true }) cmd("ThemeSwitcher", function() - require("taken.functions.themes").themeselector() + require("taken.utils.themes").themeselector() end, { desc = "Select a theme", }) @@ -34,6 +34,6 @@ autocmd("BufWritePre", { group = mkdirrun, pattern = { "*" }, callback = function() - require("taken.functions.mkdir").run() + require("taken.utils.mkdir").run() end, }) diff --git a/lua/taken/core/init.lua b/lua/taken/core/init.lua index f3c2333..54a656a 100644 --- a/lua/taken/core/init.lua +++ b/lua/taken/core/init.lua @@ -1,5 +1,5 @@ +require("taken.core.bootstrap") require("taken.core.cmd") require("taken.core.opts") require("taken.core.gui") require("taken.core.remaps") -require("taken.core.bootstrap") diff --git a/lua/taken/core/remaps.lua b/lua/taken/core/remaps.lua index c12a51e..195bd6d 100644 --- a/lua/taken/core/remaps.lua +++ b/lua/taken/core/remaps.lua @@ -1,91 +1,67 @@ -local set = vim.keymap.set +local M = { + v = { + ["J"] = { ":m '>+1gv=gv" }, + ["K"] = { ":m '<-2gv=gv" }, + }, + n = { + ["P"] = { [["+p]], desc = "Paste from sys clipboard" }, -local v = { - ["J"] = { ":m '>+1gv=gv" }, - ["K"] = { ":m '<-2gv=gv" }, + ["J"] = { "mzJ`z" }, + [""] = { "zz" }, + [""] = { "zz" }, + ["n"] = { "nzzzv" }, + ["N"] = { "Nzzzv" }, + + ["Q"] = { "" }, + ["0"] = { "^", desc = "Go to first non blank character in line" }, + + ["0"] = { "0", desc = "Go to true line beggining" }, + ["q"] = { ":noh" }, + -- buffer + ["bf"] = { vim.lsp.buf.format, desc = "Format buffer" }, + ["bs"] = { ":write ", desc = "Save buffer" }, + [""] = { "cnextzz" }, + [""] = { "cprevzz" }, + ["k"] = { "lnextzz" }, + ["j"] = { "lprevzz" }, + + -- window movement + ["ww"] = { "w", desc = "Move between splits" }, + ["wc"] = { "c", desc = "Close split" }, + ["wv"] = { "v", desc = "Vertical split" }, + ["ws"] = { "s", desc = "Horizontal split" }, + + [""] = { + function() + if vim.bo.filetype ~= "lua" then + vim.notify("Not a lua file") + return + end + + vim.cmd("so") + end, + desc = "Source current file", + }, + + ["ht"] = { + function() + require("taken.utils.themes").themeselector() + end, + desc = "Theme selector", + }, + + ["sr"] = { + [[:%s/\<\>//gI]], + desc = "Replace all instances of the word on cursor", + }, + + -- lazy + ["lu"] = { "Lazy", desc = "Lazy UI" }, + }, + vn = { + ["y"] = { [["+y]], desc = "Yank in to sys clipboard" }, + ["d"] = { [["_d]], desc = "Actually deletes text" }, + }, } -local n = { - ["P"] = { [["+p]], desc = "Paste from sys clipboard" }, - - ["J"] = { "mzJ`z" }, - [""] = { "zz" }, - [""] = { "zz" }, - ["n"] = { "nzzzv" }, - ["N"] = { "Nzzzv" }, - - ["Q"] = { "" }, - ["0"] = { "^", desc = "Go to first non blank character in line" }, - - ["0"] = { "0", desc = "Go to true line beggining" }, - ["q"] = { ":noh" }, - -- buffer - ["bf"] = { vim.lsp.buf.format, desc = "Format buffer" }, - ["bs"] = { ":write ", desc = "Save buffer" }, - [""] = { "cnextzz" }, - [""] = { "cprevzz" }, - ["k"] = { "lnextzz" }, - ["j"] = { "lprevzz" }, - - -- window movement - ["ww"] = { "w", desc = "Move between splits" }, - ["wc"] = { "c", desc = "Close split" }, - ["wv"] = { "v", desc = "Vertical split" }, - ["ws"] = { "s", desc = "Horizontal split" }, - - [""] = { - function() - if vim.bo.filetype ~= "lua" then - vim.notify("Not a lua file") - return - end - - vim.cmd("so") - end, - desc = "Source current file", - }, - - ["ht"] = { - function() - require("taken.functions.themes").themeselector() - end, - desc = "Theme selector", - }, - - ["sr"] = { - [[:%s/\<\>//gI]], - desc = "Replace all instances of the word on cursor", - }, - - -- lazy - ["lu"] = { "Lazy", desc = "Lazy UI" }, -} - -local vn = { - ["y"] = { [["+y]], desc = "Yank in to sys clipboard" }, - ["d"] = { [["_d]], desc = "Actually deletes text" }, -} - -for map, command in pairs(v) do - if command.desc then - set("v", map, command[1], { desc = command.desc, silent = true }) - else - set("v", map, command[1], { silent = true }) - end -end - -for map, command in pairs(n) do - if command.desc then - set("n", map, command[1], { desc = command.desc, silent = true }) - else - set("n", map, command[1], { silent = true }) - end -end - -for map, command in pairs(vn) do - if command.desc then - set({ "v", "n" }, map, command[1], { desc = command.desc, silent = true }) - else - set({ "v", "n" }, map, command[1], { silent = true }) - end -end +require("taken.utils.maps").setmap(M) diff --git a/lua/taken/plugins/lsp/lspconfig.lua b/lua/taken/plugins/lsp/lspconfig.lua index f110793..96017db 100644 --- a/lua/taken/plugins/lsp/lspconfig.lua +++ b/lua/taken/plugins/lsp/lspconfig.lua @@ -11,7 +11,7 @@ return { local lspconfig = require("lspconfig") local cmp_nvim_lsp = require("cmp_nvim_lsp") - local on_attach = require("taken.core.on_attach") + local on_attach = require("taken.utils.on_attach") local capabilities = cmp_nvim_lsp.default_capabilities() local signs = { Error = " ", Warn = " ", Hint = "ﴞ ", Info = " " } diff --git a/lua/taken/plugins/lsp/ts-tools.lua b/lua/taken/plugins/lsp/ts-tools.lua index 8d56374..4da409b 100644 --- a/lua/taken/plugins/lsp/ts-tools.lua +++ b/lua/taken/plugins/lsp/ts-tools.lua @@ -16,7 +16,7 @@ return { local typescript_tools = require("typescript-tools") local cmp_nvim_lsp = require("cmp_nvim_lsp") - local on_attach = require("taken.core.on_attach") + local on_attach = require("taken.utils.on_attach") local capabilities = cmp_nvim_lsp.default_capabilities() typescript_tools.setup({ diff --git a/lua/taken/utils/maps.lua b/lua/taken/utils/maps.lua new file mode 100644 index 0000000..a28d143 --- /dev/null +++ b/lua/taken/utils/maps.lua @@ -0,0 +1,34 @@ +local M = {} +local set = vim.keymap.set + +function M.setmap(maps) + local v = maps.v or {} + local n = maps.n or {} + local vn = maps.vn or {} + + for map, command in pairs(v) do + if command.desc then + set("v", map, command[1], { desc = command.desc, silent = true }) + else + set("v", map, command[1], { silent = true }) + end + end + + for map, command in pairs(n) do + if command.desc then + set("n", map, command[1], { desc = command.desc, silent = true }) + else + set("n", map, command[1], { silent = true }) + end + end + + for map, command in pairs(vn) do + if command.desc then + set({ "v", "n" }, map, command[1], { desc = command.desc, silent = true }) + else + set({ "v", "n" }, map, command[1], { silent = true }) + end + end +end + +return M diff --git a/lua/taken/functions/mkdir.lua b/lua/taken/utils/mkdir.lua similarity index 100% rename from lua/taken/functions/mkdir.lua rename to lua/taken/utils/mkdir.lua diff --git a/lua/taken/core/on_attach.lua b/lua/taken/utils/on_attach.lua similarity index 100% rename from lua/taken/core/on_attach.lua rename to lua/taken/utils/on_attach.lua diff --git a/lua/taken/functions/themes.lua b/lua/taken/utils/themes.lua similarity index 100% rename from lua/taken/functions/themes.lua rename to lua/taken/utils/themes.lua