-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
384 lines (366 loc) · 16.1 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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
------------------------- LAZY PLUGIN MANAGER ---------------------------------
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
local lazy_url = "https://github.com/folke/lazy.nvim"
-- stylua: ignore start
vim.fn.system({ "git", "clone", "--filter=blob:none", lazy_url, "--branch=stable", lazypath, })
-- stylua: ignore stop
end
------------------------- USER OPTIONS ----------------------------------------
local o = vim.opt
local wo = vim.wo
local g = vim.g
g.mapleader = ";"
g.maplocalleader = ";"
-- stylua: ignore start
g.have_nerd_font = true -- set to false if you don't have a nerd font
o.backspace = "" -- influences the working of <BS>, etc. see `:h 'backspace'`
o.backup = false -- <true|false> make a backup before overwriting a file?
o.breakindent = true -- <true|false> Will every wrapped line continue visually indented?
o.clipboard = "unnamedplus" -- <string> set clipboard mode - see `:h 'clipboard'`
o.cmdheight = 1 -- <int> space for displaying messages/commands?
o.completeopt = { "menu", "menuone", "noselect", "noinsert" } -- options for Insert mode completion
o.conceallevel = 3 -- {0,1,2,3} Determine how text with "conceal" is shown
o.cursorline = true -- <true|false> highlight the current line?
o.expandtab = true -- <true | false> convert tabs to spaces?
o.fileencoding = "utf-8" -- <fileencodings> file-content encoding for the current buffer
o.fillchars = { fold = "·" } -- see `:h 'fillchars'`
o.foldcolumn = "0" -- <string> 'auto' or number of columns to use for the fold column
o.foldenable = false -- <true|false> all folds closed on buffer open? (zi to toggle)
o.foldtext = "v:lua.myfolds()" -- see lua/user/funs.lua
o.history = 500 -- <number> a history of ":" and search commands (max 10000)
o.hlsearch = true -- <boolean> highlight all matches on previous search pattern
o.ignorecase = false -- <boolean> ignore case in search patterns
o.laststatus = 3 -- {0,1,2,3} should the last window will have a status line? See `:h laststatus`
o.lazyredraw = true -- <boolean> redraw screen while running macros? (true = faster)
o.list = true -- <boolean> show some invisible characters (tabs, eol, etc.)
o.mouse = "" -- <string> enable mouse support in which situations? See `:h 'mouse'`
o.number = true -- <boolean> print the line number in front of each line?
o.path = ".,**" -- <string> search paths. See `:h 'path'` and `:h starstar-wildcard`
o.relativenumber = true -- <boolean> show relative line numbers?
o.rtp:prepend(lazypath) -- add lazy to rtp
o.scrolloff = 3 -- <number> minimum number of screen lines to keep above and below the cursor
o.shiftwidth = 2 -- <number> the number of spaces inserted for each indentation
o.shortmess = o.shortmess + "c" -- prevent "pattern not found" messages
o.showmode = false -- <boolean> show the mode? (redundant if mode is built into the statusline)
o.sidescrolloff = 5 -- <number> the minimal number of columns to scroll horizontally
o.signcolumn =
"yes" -- <string> in {auto, no, yes, 1-9} - "yes" prevents gutter opening and closing spastically
o.smartcase = true -- <boolean> override the 'ignorecase' option if the search pattern contains upper case characters?
o.smartindent = true -- <boolean> make indenting smarter again?
o.spelllang = "en_ca" -- <string> language(s) to use for spell checking
o.splitbelow = true -- <boolean> force all horizontal splits to go below current window?
o.splitright = true -- <boolean> force all vertical splits to go to the right of current window?
o.swapfile = true -- <boolean> enable/disable swap file creation?
o.tabstop = 2 -- <number> default: 8 - how many columns does a tab counts for?
o.termguicolors = true -- <boolean> enable 24-bit RGB color in the TUI?
o.timeoutlen = 400 -- <number> time to wait for a mapped sequence to complete (in milliseconds)
o.ttimeoutlen = 0 -- <number> time in milliseconds to wait for a key code sequence to complete
o.undofile = true -- <boolean> enable/disable undo file creation?
o.updatetime = 1000 -- <number> if nothing is typed after this many milliseconds the swap file will be written to disk
o.wildignorecase = true -- <boolean> ignore setcase when completing file names and directories?
o.wildmode = "full" -- <string> how to complete file names and directories
o.wrap = false -- <boolean> wrap lines at the screen edge?
wo.foldexpr =
"nvim_treesitter#foldexpr()" -- foldexpr for treesitter. See `:h fold-expr` and `:h nvim_treesitter#foldexpr()`
wo.foldmethod = "expr" -- <string> foldmethod to use. See `:h foldmethod`
-- stylua: ignore end
local non_plugin_maps = {
-- stylua: ignore start
{ "<Esc>", "<cmd>nohlsearch<CR>" },
{ "<F2>", function() vim.cmd(":wa|mksession!") end, desc = "Save session and files", },
{ "<F3>", function() vim.cmd(":so Session.vim") end, desc = "Load session", },
{ "<F4>", ":setlocal spell!<CR>", desc = "Toggle spellcheck" },
{ "-", "<cmd>Oil<CR>", desc = "Browse files with Oil" },
{ "<C-w>b", "<cmd>bdelete<CR>", desc = "Close buffer" },
{ "<leader>h", ":help ", desc = "Help topics", icon = "", silent = false },
{ "<leader>b", ":buffer ", desc = "Buffers", icon = "", silent = false },
{ "<leader>f", ":find ", desc = "Files", icon = "", silent = false },
{ "<leader>g", ":Grep ", desc = "Grep", icon = "", silent = false },
{ "<leader>w", "<cmd>Vex<CR>", desc = "Browse files", icon = "" },
{ "<leader>q", vim.diagnostic.setloclist, desc = "Diagnostics", icon = "", },
-- stylua: ignore start
}
-- define your installed LSP servers here
local servers = {
lua_ls = {
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
"${3rd}/love2d/library",
},
},
},
},
},
rust_analyzer = {},
ts_ls = {},
tailwindcss = {},
svelte = {},
cssls = {},
pyright = {},
}
-- define your installed formatters here
local prettier = { "prettierd", "prettier", stop_after_first = true }
local formatters_by_ft = {
bash = { "shfmt" },
lua = { "stylua" },
javascript = prettier,
javascriptreact = prettier,
typescript = prettier,
typescriptreact = prettier,
svelte = prettier,
python = { "black" },
vue = prettier,
["*"] = { "codespell" }, -- always run
["_"] = { "trim_whitespace" },
}
------------------------- HELPERS ---------------------------------------------
vim.cmd("command! -nargs=+ Grep execute 'silent grep! <args>' | copen")
-- Custom fold
function _G.myfolds()
local line = vim.fn.getline(vim.v.foldstart)
local line_count = vim.v.foldend - vim.v.foldstart + 1
return line .. " ·········· " .. line_count .. " lines "
end
------------------------- LOAD PLUGINS ----------------------------------------
require("lazy").setup({
spec = {
"tpope/vim-sleuth", --- https://github.com/tpope/vim-sleuth
"tpope/vim-fugitive", --- https://github.com/tpope/vim-fugitive
"tpope/vim-surround", --- https://github.com/tpope/vim-surround
{ --- https://github.com/folke/tokyonight.nvim
"folke/tokyonight.nvim",
priority = 1000,
config = function()
vim.cmd("colorscheme tokyonight")
end,
},
{
"majamin/buffy.nvim",
opts = {},
},
{
"stevearc/oil.nvim", -- https://github.com/stevearc/oil.nvim/releases
cmd = { "Oil" },
opts = {},
},
{ --- https://github.com/echasnovski/mini.statusline
"echasnovski/mini.statusline",
opts = {},
version = "*",
},
{ --- https://github.com/echasnovski/mini.indentscope
"echasnovski/mini.indentscope",
config = function()
require("mini.indentscope").setup({
-- stylua: ignore start
draw = { delay = 0, animation = function() return 0 end },
symbol = "░",
-- stylua: ignore end
})
vim.api.nvim_set_hl(0, "MiniIndentscopeSymbol", { link = "NonText" })
end,
},
{ --- https://github.com/windwp/nvim-autopairs
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true,
},
{ --- https://github.com/lewis6991/gitsigns.nvim
"lewis6991/gitsigns.nvim",
config = true,
},
{ --- https://github.com/folke/lazydev.nvim
"folke/lazydev.nvim",
event = { "BufReadPost", "BufNewFile" },
ft = "lua", -- only load on lua files
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
{ --- https://github.com/saghen/blink.cmp
"saghen/blink.cmp",
dependencies = "rafamadriz/friendly-snippets",
version = "*",
opts = {
completion = {
ghost_text = { enabled = true },
menu = {
border = "single",
auto_show = function(ctx) -- don't auto show except for cmdline and path
return (ctx.mode == "cmdline") or (ctx.mode == "path")
end,
},
documentation = { auto_show = true, window = { border = "single" } },
},
signature = { enabled = true, window = { border = "single" } },
keymap = {
preset = "super-tab",
["<C-n>"] = { "show", "select_next", "fallback" },
},
cmdline = {
keymap = {
preset = "super-tab",
["<Up>"] = { "fallback" },
["<Down>"] = { "fallback" },
["<C-n>"] = { "show", "select_next", "fallback" },
["<C-p>"] = { "show", "select_prev", "fallback" },
},
},
sources = {
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100,
},
path = { opts = { show_hidden_files_by_default = true } },
},
},
},
},
{ --- https://github.com/neovim/nvim-lspconfig
"neovim/nvim-lspconfig",
dependencies = { "saghen/blink.cmp" },
event = { "BufReadPost", "BufNewFile" },
cmd = { "LspInfo", "LspInstall", "LspUninstall" },
opts = {
servers = servers,
},
config = function(_, opts)
local lspconfig = require("lspconfig")
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup(
"user-lsp-attach",
{ clear = true }
),
callback = function(event)
local wk = require("which-key")
wk.add({
-- stylua: ignore start
{ "<leader>l", group = "LSP", icon = "" },
{ "<leader>lr", vim.lsp.buf.rename, desc = "LSP: Rename" },
{ "<leader>la", vim.lsp.buf.code_action, desc = "LSP: Code Action" },
{ "K", vim.lsp.buf.hover, desc = "LSP: Hover Documentation" },
{ "gd", vim.lsp.buf.definition, desc = "LSP: Goto Definition" },
{ "gD", vim.lsp.buf.declaration, desc = "LSP: Goto Declaration" },
-- stylua: ignore end
})
local client = vim.lsp.get_client_by_id(event.data.client_id)
if
client
and client.server_capabilities.inlayHintProvider
and vim.lsp.inlay_hint
then
vim.lsp.inlay_hint.enable()
end
end,
})
for server, config in pairs(opts.servers) do
-- passing config.capabilities to blink.cmp merges with the capabilities in your
-- `opts[server].capabilities, if you've defined it
config.capabilities =
require("blink.cmp").get_lsp_capabilities(config.capabilities)
lspconfig[server].setup(config)
end
end,
},
{ --- https://github.com/stevearc/conform.nvim
"stevearc/conform.nvim",
event = { "BufReadPost", "BufWritePre" },
cmd = { "Format", "ConformInfo" },
config = function()
local conform = require("conform")
---@module "conform"
---@type conform.setupOpts
local opts = {
async = true,
default_format_opts = {
lsp_format = "fallback",
},
formatters_by_ft = formatters_by_ft,
format_on_save = { timeout_ms = 200 },
formatters = {
shfmt = {
prepend_args = { "-i", "2" },
},
},
}
local wk = require("which-key")
wk.add({
{
"<leader><leader>",
conform.format,
desc = "Format buffer",
icon = "",
},
})
conform.setup(opts)
end,
},
{ --- https://github.com/windwp/nvim-ts-autotag
"windwp/nvim-ts-autotag",
event = { "BufReadPre", "BufNewFile" },
config = function()
require("nvim-ts-autotag").setup({
opts = {
enable_close = true,
enable_rename = true,
enable_close_on_slash = false,
},
})
end,
},
{ --- https://github.com/nvim-treesitter/nvim-treesitter
"nvim-treesitter/nvim-treesitter",
cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
build = ":TSUpdate",
event = {
"BufReadPost",
"BufNewFile",
},
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
incremental_selection = {
enable = true,
keymaps = {
init_selection = " ",
node_incremental = " ",
scope_incremental = "gi",
node_decremental = "g ",
},
},
highlight = {
enable = true,
additional_vim_regex_highlighting = { "ruby" },
},
indent = { enable = true, disable = { "ruby" } },
})
end,
},
{ --- https://github.com/folke/which-key.nvim
"folke/which-key.nvim",
config = function()
local wk = require("which-key")
wk.setup({
preset = "helix",
delay = 1400,
})
wk.add(non_plugin_maps)
end,
},
},
install = { colorscheme = { "slate" } },
checker = { enabled = false },
})