-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.lua
396 lines (370 loc) · 12.8 KB
/
config.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
385
386
387
388
389
390
391
392
393
394
395
396
--[[
lvim is the global options object
curl -fsSL https://raw.githubusercontent.com/ronniedroid/getnf/master/install.sh | bash
Linters should be
filled in as strings with either
a global executable or a path to
an executable
]]
-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
vim.cmd("let g:python3_host_prog = '/Users/dele/pyenv/bin/python'")
-- general
lvim.log.level = "warn"
lvim.format_on_save = true
-- lvim.transparent_window = true
lvim.colorscheme = "catppuccin"
-- to disable icons and use a minimalist setup, uncomment the following
-- lvim.use_icons = false
-- keymappings [view all the defaults by pressing <leader>Lk]
lvim.leader = ","
-- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
lvim.keys.normal_mode["d"] = '"_d'
lvim.keys.normal_mode["c"] = '"_c'
-- unmap a default keymapping
-- vim.keymap.del("n", "<C-Up>")
-- override a default keymapping
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- or vim.keymap.set("n", "<C-q>", ":q<cr>" )
lvim.keys.insert_mode["kj"] = "<ESC>"
lvim.keys.normal_mode["<S-l>"] = ":BufferLineCycleNext<CR>"
lvim.keys.normal_mode["<S-h>"] = ":BufferLineCyclePrev<CR>"
lvim.keys.normal_mode["<leader><S-g>"] = ":Glow<CR>"
-- lvim.keys.normal_mode["<C-t>"] = ":ToggleTerm size=20 dir=. direction=horizontal<CR>"
-- Remap Lightspeed , to avoid leader
-- vim.cmd("noremap <leader>, g:lightspeed_last_motion == \'sx\' ? \"<Plug>Lightspeed_,_sx\" : \"<Plug>Lightspeed_,_ft\"")
-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
-- local _, actions = pcall(require, "telescope.actions")
-- lvim.builtin.telescope.defaults.mappings = {
-- -- for input mode
-- i = {
-- ["<C-j>"] = actions.move_selection_next,
-- ["<C-k>"] = actions.move_selection_previous,
-- ["<C-n>"] = actions.cycle_history_next,
-- ["<C-p>"] = actions.cycle_history_prev,
-- },
-- -- for normal mode
-- n = {
-- ["<C-j>"] = actions.move_selection_next,
-- ["<C-k>"] = actions.move_selection_previous,
-- },
-- }
-- Use which-key to add extra bindings with the leader-key prefix
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" }
lvim.builtin.which_key.mappings["t"] = {
name = "+Trouble",
r = { "<cmd>Trouble lsp_references<cr>", "References" },
f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
d = { "<cmd>Trouble document_diagnostics<cr>", "Diagnostics" },
q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
l = { "<cmd>Trouble loclist<cr>", "LocationList" },
w = { "<cmd>Trouble workspace_diagnostics<cr>", "Wordspace Diagnostics" },
}
-- TODO: User Config for predefined plugins
lvim.builtin.alpha.active = true
lvim.builtin.alpha.mode = "dashboard"
lvim.builtin.terminal.active = true
lvim.builtin.treesitter.context_commentstring = nil
-- require('ts_context_commentstring').setup {
-- enable_autocmd = false,
-- languages = {
-- typescript = '// %s',
-- },
-- }
lvim.builtin.treesitter.highlight.enabled = true
lvim.builtin.treesitter.highlight.enable = true
lvim.builtin.treesitter.playground.enable = true
lvim.builtin.nvimtree.setup.view.side = "left"
lvim.builtin.nvimtree.setup.renderer.icons.show.git = false
-- if you don't want all the parsers change this to a table of the ones you want
lvim.builtin.treesitter.ensure_installed = {
"bash",
"go",
"gomod",
"c",
"javascript",
"json",
"lua",
"python",
"typescript",
"tsx",
"css",
"rust",
"yaml",
"svelte",
"toml",
}
lvim.builtin.treesitter.ignore_install = { "haskell" }
-- generic LSP settings
-- ---@usage disable automatic installation of servers
-- lvim.lsp.automatic_servers_installation = false
-- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!!
-- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))`
-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" })
-- local opts = {} -- check the lspconfig documentation for a list of all possible options
-- require("lvim.lsp.manager").setup("pyright", opts)
-- require("lvim.lsp.manager").setup("remark_ls")
require("lvim.lsp.manager").setup("tsserver")
require("lvim.lsp.manager").setup("html")
require("lvim.lsp.manager").setup("gopls")
require("lvim.lsp.manager").setup("tailwindcss")
require("lvim.lsp.manager").setup("svelte")
require("lvim.lsp.manager").setup("bashls")
require("lvim.lsp.manager").setup("lua_ls")
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" })
pcall(function()
require("rust-tools").setup {
tools = {
executor = require("rust-tools/executors").termopen, -- can be quickfix or termopen
reload_workspace_from_cargo_toml = true,
runnables = {
use_telescope = true,
},
inlay_hints = {
auto = true,
only_current_line = false,
show_parameter_hints = false,
parameter_hints_prefix = "<-",
other_hints_prefix = "=>",
max_len_align = false,
max_len_align_padding = 1,
right_align = false,
right_align_padding = 7,
highlight = "Comment",
},
hover_actions = {
border = "rounded",
},
on_initialized = function()
vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, {
pattern = { "*.rs" },
callback = function()
local _, _ = pcall(vim.lsp.codelens.refresh)
end,
})
end,
},
server = {
on_attach = function(client, bufnr)
require("lvim.lsp").common_on_attach(client, bufnr)
local rt = require "rust-tools"
vim.keymap.set("n", "K", rt.hover_actions.hover_actions, { buffer = bufnr })
end,
capabilities = require("lvim.lsp").common_capabilities(),
settings = {
["rust-analyzer"] = {
lens = {
enable = true,
},
checkOnSave = {
enable = true,
command = "clippy",
},
},
},
},
}
end)
-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!!
-- ---`:LvimInfo` lists which server(s) are skiipped for the current filetype
-- vim.tbl_map(function(server)
-- return server ~= "emmet_ls"
-- end, lvim.lsp.automatic_configuration.skipped_servers)
-- -- you can set a custom on_attach function that will be used for all the language servers
-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion>
-- lvim.lsp.on_attach_callback = function(client, bufnr)
-- local function buf_set_option(...)
-- vim.api.nvim_buf_set_option(bufnr, ...)
-- end
-- --Enable completion triggered by <c-x><c-o>
-- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- end
-- Fix on MacOS (or just LunarVim on svelte LSP wathcing ts file change)
lvim.lsp.on_attach_callback = function(client, bufnr)
if client.name == "svelte" then
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { "*.js", "*.ts" },
group = vim.api.nvim_create_augroup("svelte_ondidchangetsorjsfile", { clear = true }),
callback = function(ctx)
-- Here use ctx.match instead of ctx.file
client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match })
end,
})
end
end
-- local null_ls = require("null-ls")
-- local sources = {
-- null_ls.builtins.formatting.sqlfluff.with({
-- args = { "lint", "--disable-progress-bar", "-f", "github-annotation", "-n", "$FILENAME" },
-- extra_args = {
-- "--dialect", "postgres" }
-- })
-- }
-- null_ls.setup({ sources = sources })
-- -- set a formatter, this will override the language server formatting capabilities (if it exists)
-- {
-- -- each formatter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
-- command = "prettier",
-- ---@usage arguments to pass to the formatter
-- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}`
-- extra_args = { "--print-with", "100" },
-- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports.
-- filetypes = { "typescript", "typescriptreact" },
-- },
local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
{ command = "gofmt", filetypes = { "go" } },
{ command = "beautysh", filetypes = { "bash", "sh" } },
{ command = "prettier", extra_filetypes = { "svelte" } },
{ command = "sqlfluff", extra_args = { "--dialect", "sqlite" } },
-- { command = "prettierd", },
}
-- -- set additional linters
-- local linters = require "lvim.lsp.null-ls.linters"
-- linters.setup {
-- { command = "flake8", filetypes = { "python" } },
-- {
-- -- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration
-- command = "shellcheck",
-- ---@usage arguments to pass to the formatter
-- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}`
-- extra_args = { "--severity", "warning" },
-- },
-- {
-- command = "codespell",
-- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports.
-- filetypes = { "javascript", "python" },
-- },
-- }
local linters = require "lvim.lsp.null-ls.linters"
linters.setup {
{ command = "golangci_lint", filetypes = { "go" } },
-- { command = "eslint", extra_filetypes = { "svelte" } },
{ command = "jsonlint", filetypes = { "json" } },
{ command = "sqlfluff", extra_args = { "--dialect", "sqlite" } },
}
-- Additional Plugins
lvim.plugins = {
"simrat39/rust-tools.nvim",
{
"saecki/crates.nvim",
version = "v0.3.0",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("crates").setup {
null_ls = {
enabled = true,
name = "crates.nvim",
},
popup = {
border = "rounded",
},
}
end,
},
{
"tomasiser/vim-code-dark",
},
{
"norcalli/nvim-colorizer.lua",
config = function()
require("colorizer").setup({ "css", "scss", "html", "javascript", "typescriptreact", "svelte" }, {
RGB = true, -- #RGB hex codes
RRGGBB = true, -- #RRGGBB hex codes
RRGGBBAA = true, -- #RRGGBBAA hex codes
rgb_fn = true, -- CSS rgb() and rgba() functions
hsl_fn = true, -- CSS hsl() and hsla() functions
css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
})
end,
},
{
"folke/tokyonight.nvim",
opts = { style = "moon" },
},
{ "ellisonleao/gruvbox.nvim" },
{
"catppuccin/nvim",
name = "catppuccin",
opts = {
integrations = {
aerial = true,
alpha = true,
cmp = true,
dashboard = true,
flash = true,
gitsigns = true,
headlines = true,
illuminate = true,
indent_blankline = { enabled = true },
leap = true,
lsp_trouble = true,
mason = true,
markdown = true,
mini = true,
native_lsp = {
enabled = true,
underlines = {
errors = { "undercurl" },
hints = { "undercurl" },
warnings = { "undercurl" },
information = { "undercurl" },
},
},
navic = { enabled = true, custom_bg = "lualine" },
neotest = true,
neotree = true,
noice = true,
notify = true,
semantic_tokens = true,
telescope = true,
treesitter = true,
treesitter_context = true,
which_key = true,
},
},
},
-- {
-- "ggandor/lightspeed.nvim",
-- event = "BufRead",
-- },
{
"ggandor/leap.nvim",
name = "leap",
config = function()
require("leap").add_default_mappings()
end,
},
{
"windwp/nvim-ts-autotag",
event = "InsertEnter",
config = function()
require("nvim-ts-autotag").setup()
end,
},
{
"folke/lsp-colors.nvim",
event = "BufRead",
},
{
"folke/trouble.nvim",
cmd = "TroubleToggle",
},
{
"ellisonleao/glow.nvim",
},
}
-- Autocommands (https://neovim.io/doc/user/autocmd.html)
-- vim.api.nvim_create_autocmd("BufEnter", {
-- pattern = { "*.json", "*.jsonc" },
-- -- enable wrap mode for json files only
-- command = "setlocal wrap",
-- })
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = "zsh",
-- callback = function()
-- -- let treesitter use bash highlight for zsh files as well
-- require("nvim-treesitter.highlight").attach(0, "bash")
-- end,
-- })