My neovim config
1local vim = vim
2vim.pack.add({
3 { src = "https://github.com/stevearc/oil.nvim" },
4 { src = "https://github.com/nvim-mini/mini.icons" },
5 { src = "https://github.com/nvim-mini/mini.pick" },
6
7 { src = "https://github.com/lewis6991/gitsigns.nvim" },
8 { src = "https://github.com/windwp/nvim-autopairs" },
9 { src = "https://github.com/j-hui/fidget.nvim" },
10 { src = "https://github.com/folke/todo-comments.nvim" },
11 { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" },
12
13 -- { src = "https://github.com/numToStr/Comment.nvim" },
14
15 { src = "https://github.com/saghen/blink.cmp", version = "v1.9.1" },
16 { src = "https://github.com/rafamadriz/friendly-snippets" },
17
18 { src = "https://github.com/smoka7/hop.nvim" },
19 { src = "https://github.com/folke/trouble.nvim" },
20 -- themes
21 { src = "https://github.com/vague-theme/vague.nvim" },
22 { src = "https://github.com/IroncladDev/osmium" },
23 { src = "https://github.com/serhez/teide.nvim" },
24 { src = "https://github.com/sainnhe/everforest" },
25
26 -- Mason / Lsp
27 { src = "https://github.com/mason-org/mason.nvim.git" },
28 { src = "https://github.com/mason-org/mason-lspconfig.nvim.git" },
29 { src = "https://github.com/neovim/nvim-lspconfig.git" },
30 { src = "https://github.com/nvim-lua/plenary.nvim" },
31 { src = "https://github.com/olrtg/nvim-emmet" },
32 { src = "https://github.com/stevearc/conform.nvim" },
33 { src = "https://github.com/pmizio/typescript-tools.nvim" },
34})
35
36vim.o.number = true
37vim.o.relativenumber = true
38vim.o.mouse = "a"
39vim.o.showmode = false
40vim.o.clipboard = "unnamedplus"
41vim.o.breakindent = true
42vim.o.undofile = true
43vim.o.ignorecase = true
44vim.o.smartcase = true
45vim.o.signcolumn = "yes"
46vim.o.updatetime = 250
47vim.o.timeoutlen = 600
48vim.o.splitright = true
49vim.o.splitbelow = true
50vim.o.inccommand = "split"
51vim.o.cursorline = true
52vim.o.swapfile = false
53vim.o.scrolloff = 10
54vim.o.hlsearch = true
55vim.o.list = true
56vim.o.wrap = false
57vim.o.tabstop = 4
58vim.o.shiftwidth = 4
59vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
60
61vim.g.mapleader = " "
62vim.g.maplocalleader = " "
63vim.g.have_nerd_font = true
64vim.o.winborder = "rounded"
65
66require("osmium").setup({
67 integrations = {
68 gitsigns = false,
69 telescope = true,
70 indent_blankline = false,
71 fff = false,
72 },
73 transparent_bg = false, -- whether to use a transparent background
74 show_end_of_buffer = false, -- whether to show the end of buffer
75})
76
77vim.g.everforest_background = "hard"
78vim.g.everforest_better_performance = 1
79vim.o.background = "dark"
80
81vim.cmd("colorscheme everforest")
82vim.cmd(":hi statusline guibg=NONE")
83
84local keymaps = function()
85 vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" })
86 vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
87 vim.keymap.set("n", "<leader>fb", "<CMD>Oil<CR>", { desc = "[F]ile [B]rowser" })
88 vim.keymap.set("n", "<leader>sf", "<CMD>Pick files<CR>", { desc = "[S]earch [F]iles" })
89 vim.keymap.set("n", "<leader>sg", "<CMD>Pick grep_live<CR>", { desc = "[S]earch by [G]rep" })
90 vim.keymap.set("n", "<leader>sr", "<CMD>Pick resume<CR>", { desc = "[S]earch [R]esume" })
91 vim.keymap.set({ "n", "v" }, "<leader>xe", require("nvim-emmet").wrap_with_abbreviation)
92 vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "[C]ode [A]ction" })
93 vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" })
94 vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "[G]oto [D]efinition" })
95 vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "[G]oto [R]eferences" })
96 vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" })
97 vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "[G]oto [I]mplementation" })
98 vim.keymap.set({ "i", "s" }, "<C-j>", function()
99 if vim.snippet.active({ direction = 1 }) then
100 vim.snippet.jump(1)
101 end
102 end, { desc = "Jump snippet next" })
103 vim.keymap.set({ "i", "s" }, "<C-k>", function()
104 if vim.snippet.active({ direction = -1 }) then
105 vim.snippet.jump(-1)
106 end
107 end, { desc = "Jump snippet back" })
108end
109
110require("mini.pick").setup({})
111
112vim.keymap.set("i", "<Tab>", function()
113 if vim.fn.pumvisible() == 1 then
114 return "<C-y>"
115 elseif vim.snippet.active({ direction = 1 }) then
116 return "<Cmd>lua vim.snippet.jump(1)<CR>"
117 else
118 return "<Tab>"
119 end
120end, { expr = true, desc = "Accept completion or jump snippet" })
121
122local ensure_installed = {
123 lsp = { "lua_ls", "emmet_ls", "oxlint", "tailwindcss" },
124 treesitter = { "lua", "typescript", "javascript", "tsx", "html", "css", "svelte" },
125}
126
127local setup_blink = function()
128 require("blink.cmp").setup({
129 keymap = { preset = "default" },
130
131 appearance = {
132 -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
133 -- Adjusts spacing to ensure icons are aligned
134 nerd_font_variant = "mono",
135 },
136
137 -- (Default) Only show the documentation popup when manually triggered
138 completion = { documentation = { auto_show = true } },
139
140 -- Default list of enabled providers defined so that you can extend it
141 -- elsewhere in your config, without redefining it, due to `opts_extend`
142 sources = {
143 default = { "lsp", "path", "snippets", "buffer" },
144 },
145
146 -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
147 -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
148 -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
149 --
150 -- See the fuzzy documentation for more information
151 fuzzy = { implementation = "prefer_rust_with_warning" },
152 })
153end
154
155local setup_conform = function()
156 require("conform").setup({
157 format_on_save = { timeout_ms = 500, lsp_fallback = true },
158 formatters_by_ft = {
159 lua = { "stylua" },
160 javascript = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
161 typescript = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
162 typescriptreact = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
163 javascriptreact = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
164 json = { "prettierd", "prettier", stop_after_first = true },
165 html = { "prettierd", "prettier", stop_after_first = true },
166 css = { "prettierd", "prettier", stop_after_first = true },
167 },
168 })
169end
170
171local setup_oil = function()
172 ---@module 'oil'
173 ---@type oil.SetupOpts
174 local opts = {
175 default_file_explorer = true,
176 columns = {
177 "icon",
178 },
179 view_options = {
180 show_hidden = true,
181 is_hidden_file = function(name)
182 return name ~= ".." and vim.startswith(name, ".")
183 end,
184 },
185 }
186 require("oil").setup(opts)
187 require("mini.icons").setup({})
188end
189
190-- hop
191local setup_hop = function()
192 local hop = require("hop")
193 local directions = require("hop.hint").HintDirection
194
195 local hopmap = function(key, direction, current_line_only)
196 vim.keymap.set("", key, function()
197 hop.hint_char1({
198 direction = direction,
199 current_line_only = current_line_only,
200 })
201 end, { remap = true })
202 end
203
204 hopmap("f", directions.AFTER_CURSOR, false)
205 hopmap("F", directions.BEFORE_CURSOR, false)
206 hopmap("t", directions.AFTER_CURSOR, true)
207 hopmap("T", directions.BEFORE_CURSOR, true)
208
209 hop.setup({
210 keys = "etovxqpdygfblzhckisuran",
211 })
212end
213--
214
215local setup_treesitter = function()
216 local parsers = ensure_installed.treesitter
217
218 require("nvim-treesitter.install").ensure_installed(parsers)
219 vim.api.nvim_create_autocmd("FileType", {
220 callback = function(args)
221 local buf, filetype = args.buf, args.match
222
223 local language = vim.treesitter.language.get_lang(filetype)
224 if not language then
225 return
226 end
227
228 -- check if parser exists and load it
229 if not vim.treesitter.language.add(language) then
230 return
231 end
232 -- enables syntax highlighting and other treesitter features
233 vim.treesitter.start(buf, language)
234
235 -- enables treesitter based folds
236 -- for more info on folds see `:help folds`
237 -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
238 -- vim.wo.foldmethod = 'expr'
239
240 -- enables treesitter based indentation
241 vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
242 end,
243 })
244end
245
246local setup_mason_and_lsp = function()
247 require("mason").setup()
248
249 local mason_lspconfig = require("mason-lspconfig")
250 local lspconfig = require("lspconfig")
251
252 local capabilities = require("blink.cmp").get_lsp_capabilities()
253
254 mason_lspconfig.setup({
255 ensure_installed = ensure_installed.lsp,
256 handlers = {
257 -- default handler for most servers
258 function(server_name)
259 lspconfig[server_name].setup({
260 capabilities = capabilities,
261 })
262 end,
263 },
264 })
265
266 -- typescript-tools.nvim setup
267 require("typescript-tools").setup({
268 capabilities = capabilities,
269 settings = {
270 expose_as_code_action = { "all" },
271 complete_function_calls = true,
272 },
273 })
274end
275
276-- Plugin setup
277setup_mason_and_lsp()
278setup_blink()
279setup_treesitter()
280
281setup_oil()
282setup_hop()
283setup_conform()
284keymaps()
285
286require("nvim-autopairs").setup({})
287require("todo-comments").setup({ signs = false })
288
289require("debug")