aboutsummaryrefslogtreecommitdiff
path: root/lua/startuptools.lua
diff options
context:
space:
mode:
authormax397574 <[email protected]>2021-10-05 15:56:09 +0200
committermax397574 <[email protected]>2021-10-05 15:56:09 +0200
commit47346a37cf885c1cbb6d2f98fa32ad89b048af47 (patch)
treea06d83dbe6e1fc471b84b4d562cca0f31afede2a /lua/startuptools.lua
parente1350f8fd753bb6f4a66e844bab523dee9e37eba (diff)
feat(plugin): ✨automatically and functionality
Diffstat (limited to 'lua/startuptools.lua')
-rw-r--r--lua/startuptools.lua47
1 files changed, 46 insertions, 1 deletions
diff --git a/lua/startuptools.lua b/lua/startuptools.lua
index 0d95c01..fca84ee 100644
--- a/lua/startuptools.lua
+++ b/lua/startuptools.lua
@@ -1,6 +1,8 @@
local M = {}
local nb = vim.api.nvim_create_namespace('noiceboard')
+local opts = { noremap = true, silent = true }
+
local settings = {
header = {
" /$$ ",
@@ -11,10 +13,27 @@ local settings = {
"| $$ | $$| $$_____/| $$ | $$ \\ $$$/ | $$| $$ | $$ | $$",
"| $$ | $$| $$$$$$$| $$$$$$/ \\ $/ | $$| $$ | $$ | $$",
"|__/ |__/ \\_______/ \\______/ \\_/ |__/|__/ |__/ |__/",
+ },
+ tools = {
+ ["Find File"] = "Telescope find_files",
+ ["Find Word"] = "Telescope live_grep",
+ ["Recent Files"] = "Telescope oldfiles",
+ ["File Browser"] = "Telescope file_browser",
+ },
+ mappings = {
}
}
+function M.check_line()
+ local line = vim.api.nvim_get_current_line()
+ for name, command in pairs(settings.tools) do
+ if line:match(name) then
+ vim.cmd(command)
+ end
+ end
+end
+
local function center(dict)
local centered = {}
local space_left = vim.o.columns - string.len(dict[1])
@@ -35,8 +54,34 @@ local function set_lines(len, text, hi, pass)
count = count + len
end
-function M.set_header()
+local function empty()
+ set_lines(1, {" "}, "TSString")
+end
+
+function M.display()
+ vim.api.nvim_buf_set_keymap(0, "n", "<CR>", ":lua require'startuptools'.check_line()<CR>", opts)
+ empty()
set_lines(#settings.header, settings.header, 'TSString')
+ local toolnames = {}
+ for name, _ in pairs(settings.tools) do
+ table.insert(toolnames, name)
+ end
+ empty()
+ set_lines(#toolnames, toolnames, 'TSString')
+ vim.cmd[[silent! %s/\s\+$//]] -- clear trailing whitespace
+ vim.api.nvim_buf_set_option(0, 'bufhidden', 'wipe')
+ vim.api.nvim_buf_set_option(0, 'buftype', 'nofile')
+ vim.api.nvim_buf_set_option(0, 'swapfile', false)
+ vim.cmd[[set nonumber
+ set norelativenumber
+ ]]
+end
+
+function M.setup()
+ vim.cmd[[
+ autocmd StdinReadPre * let s:std_in=1
+ autocmd VimEnter * lua if vim.fn.argc() == 0 and vim.fn.exists('std_in') then require"startuptools".display() end
+ ]]
end
return M