-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
124 lines (105 loc) · 3.41 KB
/
init.lua
File metadata and controls
124 lines (105 loc) · 3.41 KB
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
if vim.loader then
vim.loader.enable()
end
if not vim.keycode then
vim.keycode = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
end
if vim.version.lt(vim.version(), { 0, 9 }) then
vim.api.nvim_err_writeln 'Neovim version is too old!! please use update it'
end
if not vim.base64 then
vim.base64 = {
encode = require('utils.strings').base64_encode,
decode = require('utils.strings').base64_decode,
}
end
if not vim.list then
vim.list = {
unique = require('utils.tables').uniq_list,
}
end
vim.g.has_ui = #vim.api.nvim_list_uis() > 0
vim.g.loaded_2html_plugin = 1
-- vim.g.loaded_gzip = 1
vim.g.loaded_rrhelper = 1
vim.g.loaded_tarPlugin = 1
vim.g.loaded_zipPlugin = 1
vim.g.loaded_tutor_mode_plugin = 1
vim.g.loaded_tarPlugin = 1
vim.g.loaded_vimballPlugin = 1
vim.g.loaded_ruby_provider = 0
vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_python_provider = 0
vim.g.loaded_python3_provider = 0
vim.g.show_diagnostics = true
vim.g.alternates = {}
vim.g.tests = {}
vim.g.makefiles = {}
vim.g.short_branch_name = true
vim.g.port = 0x8AC
if vim.fn.has 'win32' == 1 then
-- vim.go.shell = 'cmd.exe'
vim.go.shell = 'powershell'
vim.go.shellcmdflag = table.concat({
'-NoLogo',
'-NoProfile',
'-ExecutionPolicy',
'RemoteSigned',
'-Command',
-- '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;',
}, ' ')
vim.go.shellredir = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
vim.go.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
vim.go.shellquote = ''
vim.go.shellxquote = ''
vim.go.shellslash = true
elseif vim.fs.basename(vim.go.shell):match '^t?csh$' then
local function executable(shell)
return vim.fn.executable(shell) == 1
end
local shell = vim.iter({ 'zsh', 'bash' }):filter(executable):map(vim.fn.exepath):peek()
if shell then
vim.go.shell = shell
end
end
vim.go.termguicolors = true
vim.g.mapleader = ' '
vim.g.minimal = vim.env.VIM_MIN ~= nil or vim.g.minimal ~= nil
vim.g.bare = vim.env.VIM_BARE ~= nil or vim.g.bare ~= nil or not vim.g.has_ui
require 'globals'
if vim.g.has_ui then
-- TODO: Add support for gum to ask for input/select items in CLI mode
require 'overloads.ui.select'
-- require 'overloads.ui.input'
-- require 'overloads.paste'
require 'completions'
require 'watch_files'
require('threads.parse').ssh_hosts()
if vim.env.TMUX_WINDOW then
local socket = vim.fn.stdpath 'cache' .. '/socket.win' .. vim.env.TMUX_WINDOW
if vim.fn.filereadable(socket) ~= 1 then
vim.fn.serverstart(socket)
end
end
require('nvim').setup(false)
vim.cmd.packadd { args = { 'matchit' }, bang = false }
if vim.version.ge(vim.version(), { 0, 12 }) then
vim.cmd.packadd { args = { 'nvim.undotree' }, bang = false }
end
else
-- TODO: This is a setup for script run using -l flag
-- Missing things,
-- - stdio handle, specially stdin; stdout/stderr works using vim.notify custom backend
-- - generic arg parsing
-- - logging to file
local hosts = require('threads.parsers').sshconfig()
for host, attrs in pairs(hosts) do
STORAGE.hosts[host] = attrs
end
end
-- NOTE: overload/replace vim.* functions
require 'overloads.ui.open'
require 'overloads.notify'