-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
235 lines (210 loc) · 8 KB
/
Copy pathinit.lua
File metadata and controls
235 lines (210 loc) · 8 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
vim.opt.termguicolors = true
vim.cmd.colorscheme("dracula")
-- ============================================================================
-- OPTIONS
-- ============================================================================
vim.opt.number = true -- line number
vim.opt.relativenumber = true -- relative line numbers
vim.opt.cursorline = true -- highlight current line
vim.opt.wrap = false -- do not wrap lines by default
vim.opt.scrolloff = 10 -- keep 10 lines above/below cursor
vim.opt.sidescrolloff = 10 -- keep 10 lines to left/right of cursor
vim.opt.tabstop = 2 -- tabwidth
vim.opt.shiftwidth = 2 -- indent width
vim.opt.softtabstop = 2 -- soft tab stop not tabs on tab/backspace
vim.opt.expandtab = true -- use spaces instead of tabs
vim.opt.smartindent = true -- smart auto-indent
vim.opt.autoindent = true -- copy indent from current line
vim.opt.ignorecase = true -- case insensitive search
vim.opt.smartcase = true -- case sensitive if uppercase in string
vim.opt.hlsearch = true -- highlight search matches
vim.opt.incsearch = true -- show matches as you type
vim.opt.signcolumn = "yes" -- always show a sign column
vim.opt.colorcolumn = "100" -- show a column at 100 position chars
vim.opt.showmatch = true -- highlights matching brackets
vim.opt.cmdheight = 1 -- single line command line
vim.opt.completeopt = "menuone,noinsert,noselect" -- completion options
vim.opt.showmode = false -- do not show the mode, instead have it in statusline
vim.opt.pumheight = 10 -- popup menu height
vim.opt.pumblend = 10 -- popup menu transparency
vim.opt.winblend = 0 -- floating window transparency
vim.opt.conceallevel = 0 -- do not hide markup
vim.opt.concealcursor = "" -- do not hide cursorline in markup
vim.opt.lazyredraw = true -- do not redraw during macros
vim.opt.synmaxcol = 300 -- syntax highlighting limit
vim.opt.fillchars = { eob = " " } -- hide "~" on empty lines
local undodir = vim.fn.expand("~/.vim/undodir")
if
vim.fn.isdirectory(undodir) == 0 -- create undodir if nonexistent
then
vim.fn.mkdir(undodir, "p")
end
vim.opt.backup = false -- do not create a backup file
vim.opt.writebackup = false -- do not write to a backup file
vim.opt.swapfile = false -- do not create a swapfile
vim.opt.undofile = true -- do create an undo file
vim.opt.undodir = undodir -- set the undo directory
vim.opt.updatetime = 300 -- faster completion
vim.opt.timeoutlen = 500 -- timeout duration
vim.opt.ttimeoutlen = 50 -- key code timeout
vim.opt.autoread = true -- auto-reload changes if outside of neovim
vim.opt.autowrite = false -- do not auto-save
vim.opt.hidden = true -- allow hidden buffers
vim.opt.errorbells = false -- no error sounds
vim.opt.backspace = "indent,eol,start" -- better backspace behaviour
vim.opt.autochdir = false -- do not autochange directories
vim.opt.iskeyword:append("-") -- include - in words
vim.opt.path:append("**") -- include subdirs in search
vim.opt.selection = "inclusive" -- include last char in selection
vim.opt.mouse = "a" -- enable mouse support
vim.opt.clipboard:append("unnamedplus") -- use system clipboard
vim.opt.modifiable = true -- allow buffer modifications
vim.opt.encoding = "utf-8" -- set encoding
vim.opt.guicursor =
"n-v-c:block,i-ci-ve:block,r-cr:hor20,o:hor50,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175" -- cursor blinking and settings
-- Folding: requires treesitter available at runtime; safe fallback if not
vim.opt.foldmethod = "expr" -- use expression for folding
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" -- use treesitter for folding
vim.opt.foldlevel = 99 -- start with all folds open
vim.opt.splitbelow = true -- horizontal splits go below
vim.opt.splitright = true -- vertical splits go right
vim.opt.wildmenu = true -- tab completion
vim.opt.wildmode = "longest:full,full" -- complete longest common match, full completion list, cycle through with Tab
vim.opt.diffopt:append("linematch:60") -- improve diff display
vim.opt.redrawtime = 10000 -- increase neovim redraw tolerance
vim.opt.maxmempattern = 20000 -- increase max memory
-- ============================================================================
-- STATUSLINE
-- ============================================================================
-- Git branch function with caching and Nerd Font icon
local cached_branch = ""
local last_check = 0
local function git_branch()
local now = vim.loop.now()
if now - last_check > 5000 then -- Check every 5 seconds
cached_branch = vim.fn.system("git branch --show-current 2>/dev/null | tr -d '\n'")
last_check = now
end
if cached_branch ~= "" then
return " \u{e725} " .. cached_branch .. " " -- nf-dev-git_branch
end
return ""
end
-- File type with Nerd Font icon
local function file_type()
local ft = vim.bo.filetype
local icons = {
lua = "\u{e620} ", -- nf-dev-lua
python = "\u{e73c} ", -- nf-dev-python
javascript = "\u{e74e} ", -- nf-dev-javascript
typescript = "\u{e628} ", -- nf-dev-typescript
javascriptreact = "\u{e7ba} ",
typescriptreact = "\u{e7ba} ",
html = "\u{e736} ", -- nf-dev-html5
css = "\u{e749} ", -- nf-dev-css3
scss = "\u{e749} ",
json = "\u{e60b} ", -- nf-dev-json
markdown = "\u{e73e} ", -- nf-dev-markdown
vim = "\u{e62b} ", -- nf-dev-vim
sh = "\u{f489} ", -- nf-oct-terminal
bash = "\u{f489} ",
zsh = "\u{f489} ",
rust = "\u{e7a8} ", -- nf-dev-rust
go = "\u{e724} ", -- nf-dev-go
c = "\u{e61e} ", -- nf-dev-c
cpp = "\u{e61d} ", -- nf-dev-cplusplus
java = "\u{e738} ", -- nf-dev-java
php = "\u{e73d} ", -- nf-dev-php
ruby = "\u{e739} ", -- nf-dev-ruby
swift = "\u{e755} ", -- nf-dev-swift
kotlin = "\u{e634} ",
dart = "\u{e798} ",
elixir = "\u{e62d} ",
haskell = "\u{e777} ",
sql = "\u{e706} ",
yaml = "\u{f481} ",
toml = "\u{e615} ",
xml = "\u{f05c} ",
dockerfile = "\u{f308} ", -- nf-linux-docker
gitcommit = "\u{f418} ", -- nf-oct-git_commit
gitconfig = "\u{f1d3} ", -- nf-fa-git
vue = "\u{fd42} ", -- nf-md-vuejs
svelte = "\u{e697} ",
astro = "\u{e628} ",
}
if ft == "" then
return " \u{f15b} " -- nf-fa-file_o
end
return ((icons[ft] or " \u{f15b} ") .. ft)
end
-- File size with Nerd Font icon
local function file_size()
local size = vim.fn.getfsize(vim.fn.expand("%"))
if size < 0 then
return ""
end
local size_str
if size < 1024 then
size_str = size .. "B"
elseif size < 1024 * 1024 then
size_str = string.format("%.1fK", size / 1024)
else
size_str = string.format("%.1fM", size / 1024 / 1024)
end
return " \u{f016} " .. size_str .. " " -- nf-fa-file_o
end
-- Mode indicators with Nerd Font icons
local function mode_icon()
local mode = vim.fn.mode()
local modes = {
n = " \u{f121} NORMAL",
i = " \u{f055} INSERT",
v = " \u{f0c4} VISUAL",
V = " \u{f0c4} V-LINE",
["\22"] = " \u{f0c4} V-BLOCK",
c = " \u{f120} COMMAND",
s = " \u{f0c5} SELECT",
S = " \u{f0c5} S-LINE",
["\19"] = " \u{f0c5} S-BLOCK",
R = " \u{f044} REPLACE",
r = " \u{f044} REPLACE",
["!"] = " \u{f489} SHELL",
t = " \u{f120} TERMINAL",
}
return modes[mode] or (" \u{f059} " .. mode)
end
_G.mode_icon = mode_icon
_G.git_branch = git_branch
_G.file_type = file_type
_G.file_size = file_size
vim.cmd([[
highlight StatusLineBold gui=bold cterm=bold
]])
-- Function to change statusline based on window focus
local function setup_dynamic_statusline()
vim.api.nvim_create_autocmd({ "WinEnter", "BufEnter" }, {
callback = function()
vim.opt_local.statusline = table.concat({
" ",
"%#StatusLineBold#",
"%{v:lua.mode_icon()}",
"%#StatusLine#",
" \u{e0b1} %f %h%m%r", -- nf-pl-left_hard_divider
"%{v:lua.git_branch()}",
"\u{e0b1} ", -- nf-pl-left_hard_divider
"%{v:lua.file_type()}",
"\u{e0b1} ", -- nf-pl-left_hard_divider
"%{v:lua.file_size()}",
"%=", -- Right-align everything after this
" \u{f017} %l:%c %P ", -- nf-fa-clock_o for line/col
})
end,
})
vim.api.nvim_set_hl(0, "StatusLineBold", { bold = true })
vim.api.nvim_create_autocmd({ "WinLeave", "BufLeave" }, {
callback = function()
vim.opt_local.statusline = " %f %h%m%r \u{e0b1} %{v:lua.file_type()} %= %l:%c %P "
end,
})
end
setup_dynamic_statusline()