-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
135 lines (118 loc) · 4.38 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---@diagnostic disable-next-line: lowercase-global
api = vim.api
-- Easier debugging
P = function(a)
print(vim.inspect(a))
end
vim.keymap.set({ "n", "t" }, "<c-s-q>", ":qa!<CR>")
-- CODE RELATED TO SEPERATING HURLUI FROM REGULAR NVIM
local old_stdpath = vim.fn.stdpath
---@diagnostic disable-next-line: duplicate-set-field
vim.fn.stdpath = function(value)
if value == "data" then
return vim.env.HURLUI_NV_DATA
end
if value == "cache" then
return vim.env.HURLUI_NV_CACHE
end
if value == "config" then
return vim.env.HURLUI_HOME
end
return old_stdpath(value)
end
vim.opt.runtimepath:remove(vim.fn.expand('~/.config/nvim'))
vim.opt.packpath:remove(vim.fn.expand('~/.local/share/nvim/site'))
vim.opt.runtimepath:append(vim.fn.stdpath('config'))
vim.opt.packpath:append(vim.fn.stdpath('data') .. '/packages')
-- Globals
DEFAULT_ENVSPACE_NAME = vim.env.DEFAULT_ENVSPACE_NAME
OUTPUT_BASE = vim.env.OUTPUT_BASE
INITIAL_CURSOR_SHAPE = vim.o.guicursor;
-- SET UP LAZY PACKAGE MANAGER
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath, }) end
vim.opt.rtp:prepend(lazypath)
--MISC SETTINGS
vim.g.mapleader = ' '
vim.o.title = true
vim.o.cursorline = true
vim.o.titlestring = 'Hurlui'
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.showtabline = 2
vim.opt.fillchars = { eob = " " }
vim.opt.shortmess:append({ I = true })
vim.opt.showmode = false
vim.opt.swapfile = false
vim.o.clipboard = "unnamedplus"
vim.opt.cmdheight = 0
vim.opt.termguicolors = true
vim.o.laststatus = 2
vim.opt.statusline = "%= %t %=" -- Center the bottom status line
vim.opt.undodir = { vim.fn.stdpath('cache') .. "/hurly/.undodir" } -- set up undodir
vim.opt.undofile = true
vim.o.splitright = true;
vim.api.nvim_tabpage_set_var(0, "purpose", "runner")
vim.cmd.tabnew()
vim.api.nvim_tabpage_set_var(0, "purpose", "env")
vim.cmd.tabprevious()
require("theme")
require("modals.jwt")
require("lazy").setup("plugins")
-- keybindings
vim.keymap.set({ "n", "t" }, "<C-h>", "<C-w>h")
vim.keymap.set({ "n", "t" }, "<C-j>", "<C-w>j")
vim.keymap.set({ "n", "t" }, "<C-k>", "<C-w>k")
vim.keymap.set({ "n", "t" }, "<C-l>", "<C-w>l")
vim.keymap.set("n", "<c-n>", function() require("modals.request"):show() end)
vim.keymap.set("n", "<c-s-d>", function() require("modals.dir"):show() end)
vim.keymap.set({ "i", "n" }, "<c-s-e>", function() if require("panels.picker").win.id then require("modals.envsetup").show() end end)
vim.keymap.set("n", "<leader>a", function() require("tabs.env"):alternate(); end);
vim.keymap.set("n", "<S-enter>", function()
local env_tab = require("tabs.env")
if api.nvim_get_current_tabpage() == env_tab.get_tabpage() then
env_tab:alternator_select(api.nvim_buf_get_name(0));
end
end);
vim.keymap.set("n", "<enter>", function()
local runner_tab = require("tabs.runner")
local env_tab = require("tabs.env")
if api.nvim_get_current_tabpage() == runner_tab.get_tabpage() then
runner_tab:run_hurl();
else
env_tab:select(api.nvim_buf_get_name(0));
env_tab:buf_labels_refresh();
end
end, { silent = true });
-- Though creating three variables that are very similar may seem like a redundancy for now
-- But this is just leaving the room for future improvements and side effect callbacks
-- AUTOCMDS
-- autosave
api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertLeave" }, {
callback = function()
if vim.bo.modified and not vim.bo.readonly and vim.fn.expand("%") ~= "" and vim.bo.buftype == "" then
api.nvim_command('silent update')
end
end,
})
-- This allows the terminal to keep up with the workspaces path
local sync_dir_with_shell = function()
vim.api.nvim_chan_send(2, '\x1b]7;file://' .. vim.fn.hostname() .. vim.fn.getcwd())
end
vim.api.nvim_create_autocmd({ "DirChanged" }, {
callback = sync_dir_with_shell
})
-- Make the window responsive
api.nvim_create_autocmd({ "VimResized" }, {
callback = function()
local tabs_runner = require("tabs.runner")
if tabs_runner.inited then
tabs_runner:update_win_size()
end
end
})
require("modals.envsetup")
TABLINE_UPDATE = function()
return require("tabs.controller"):get_line()
end
vim.go.tabline = "%!v:lua.TABLINE_UPDATE()"