-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
227 lines (209 loc) · 6.63 KB
/
init.lua
File metadata and controls
227 lines (209 loc) · 6.63 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
-- Basic Editor Settings
vim.opt.shortmess:append('I') -- Disable intro message
vim.opt.number = true -- Show line numbers
vim.opt.relativenumber = true -- Show relative line numbers
vim.opt.laststatus = 1 -- Don't show statusline
vim.opt.showmode = true
vim.opt.backspace = 'indent,eol,start'
vim.opt.hidden = true -- Allow hidden buffers
vim.opt.hlsearch = true -- Highlight search results
vim.opt.incsearch = true -- Incremental search
vim.opt.ignorecase = true -- Case insensitive search
vim.opt.smartcase = true -- Case sensitive when uppercase present
vim.opt.visualbell = true -- Visual bell instead of beeping
vim.opt.expandtab = true -- Use spaces instead of tabs
vim.opt.shiftround = true -- Round indent to multiple of shiftwidth
vim.opt.clipboard = 'unnamed' -- Use system clipboard
vim.opt.mouse = 'a' -- Enable mouse support
vim.opt.backup = false -- Disable backup files
vim.opt.writebackup = false -- Disable backup files
vim.opt.swapfile = false -- Disable swap files
-- Visual Customization
vim.opt.colorcolumn = '80' -- Show column guide at 80 characters
vim.cmd([[highlight ColorColumn ctermbg=233]])
vim.opt.foldmethod = 'indent' -- Fold based on indentation
vim.opt.foldlevel = 99 -- Start with all folds open
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--branch=stable",
lazyrepo,
lazypath
})
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Set leader keys before loading lazy.nvim
vim.g.mapleader = " " -- Space as leader key
vim.g.maplocalleader = "," -- Keeping comma as local leader for compatibility
-- Key Mappings
-- Split navigation
vim.keymap.set('n', '<C-J>', '<C-W><C-J>')
vim.keymap.set('n', '<C-K>', '<C-W><C-K>')
vim.keymap.set('n', '<C-L>', '<C-W><C-L>')
vim.keymap.set('n', '<C-H>', '<C-W><C-H>')
-- Toggle search highlighting
vim.keymap.set('n', '<leader>h', ':set hlsearch!<CR>')
-- Save with Ctrl+S
vim.keymap.set('n', '<C-S>', ':update<CR>', { silent = true })
vim.keymap.set('i', '<C-S>', '<C-O>:update<CR>', { silent = true })
-- Insert new lines without entering insert mode
vim.keymap.set('n', '<leader>o', function()
local count = vim.v.count1
vim.cmd(string.format('call append(line("."), repeat([""], %d))', count))
end, { silent = true })
vim.keymap.set('n', '<leader>O', function()
local count = vim.v.count1
vim.cmd(string.format('call append(line(".")-1, repeat([""], %d))', count))
end, { silent = true })
-- Better indentation in visual mode
vim.keymap.set('v', '<', '<gv')
vim.keymap.set('v', '>', '>gv')
-- Sort selection
vim.keymap.set('v', '<Leader>s', ':sort<CR>')
-- Filetype-specific settings
vim.api.nvim_create_autocmd('FileType', {
pattern = 'python',
callback = function()
vim.opt_local.expandtab = true
vim.opt_local.tabstop = 4
vim.opt_local.softtabstop = 4
vim.opt_local.shiftwidth = 4
vim.opt_local.autoindent = true
vim.opt_local.fileformat = 'unix'
end
})
vim.api.nvim_create_autocmd('BufNewFile', {
pattern = '*.py',
command = [[call append(0,'#! /usr/bin/env python')]]
})
vim.api.nvim_create_autocmd('FileType', {
pattern = 'cpp',
callback = function()
vim.opt_local.expandtab = true
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
end
})
vim.api.nvim_create_autocmd('FileType', {
pattern = 'html',
callback = function()
vim.opt_local.tabstop = 2
vim.opt_local.softtabstop = 2
vim.opt_local.shiftwidth = 2
end
})
vim.api.nvim_create_autocmd('FileType', {
pattern = 'javascript',
callback = function()
vim.opt_local.tabstop = 4
vim.opt_local.softtabstop = 4
vim.opt_local.shiftwidth = 4
end
})
-- Plugin configuration with lazy.nvim
require("lazy").setup({
{ "chrisgrieser/nvim-spider", lazy = true },
{ "NMAC427/guess-indent.nvim", lazy = true},
{ "saecki/live-rename.nvim" },
{
"numToStr/Comment.nvim", -- Modern commenting plugin
event = { "BufReadPre", "BufNewFile" },
config = true,
},
{
"ellisonleao/gruvbox.nvim", -- Gruvbox theme
priority = 1000, -- Load before other plugins
config = function()
require("gruvbox").setup({
contrast = "hard",
transparent_mode = true,
})
vim.cmd("colorscheme gruvbox")
vim.opt.background = "dark"
end,
},
{
"windwp/nvim-autopairs", -- Auto close brackets
event = "InsertEnter",
config = true,
},
{
"nvim-tree/nvim-tree.lua", -- File explorer
dependencies = {
"nvim-tree/nvim-web-devicons",
},
keys = {
{ "<C-t>", ":NvimTreeToggle<CR>", desc = "Toggle NvimTree" },
},
config = function()
require("nvim-tree").setup()
end,
},
{
"lewis6991/gitsigns.nvim", -- Git integration
event = { "BufReadPre", "BufNewFile" },
config = true,
},
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" },
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"python",
"lua",
"vim",
"javascript",
"cpp",
"html",
},
highlight = { enable = true },
})
end,
},
{
'MeanderingProgrammer/render-markdown.nvim',
dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' },
---@module 'render-markdown'
---@type render.md.UserConfig
opts = {},
},
}, {
install = {
colorscheme = { "gruvbox" },
},
checker = {
enabled = true, -- Automatic plugin update checking
notify = true, -- Show update notifications
},
change_detection = {
enabled = true, -- Auto-reload config changes
notify = true, -- Show reload notifications
},
})
-- Whitespace highlighting
vim.cmd([[
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
]])
-- Remove trailing whitespace
vim.keymap.set('n', '<leader>rs', function()
local save_cursor = vim.fn.getpos('.')
vim.cmd([[%s/\s\+$//e]])
vim.fn.setpos('.', save_cursor)
end, { silent = true })