my new nvim config
0
init.lua
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/saghen/blink.cmp", version = "v1.9.1" },
8 { src = "https://github.com/rafamadriz/friendly-snippets" },
9
10 { src = "https://github.com/smoka7/hop.nvim" },
11 { src = "https://github.com/folke/trouble.nvim" },
12 -- themes
13 { src = "https://github.com/vague-theme/vague.nvim" },
14 { src = "https://github.com/IroncladDev/osmium" },
15 { src = "https://github.com/serhez/teide.nvim" },
16
17 -- Mason / Lsp
18 { src = "https://github.com/mason-org/mason.nvim.git" },
19 { src = "https://github.com/mason-org/mason-lspconfig.nvim.git" },
20 { src = "https://github.com/neovim/nvim-lspconfig.git" },
21 { src = "https://github.com/nvim-lua/plenary.nvim" },
22 { src = "https://github.com/pmizio/typescript-tools.nvim" },
23 { src = "https://github.com/olrtg/nvim-emmet" },
24 { src = "https://github.com/stevearc/conform.nvim" },
25})
26
27vim.o.number = true
28vim.o.relativenumber = true
29vim.o.mouse = "a"
30vim.o.showmode = false
31vim.o.clipboard = "unnamedplus"
32vim.o.breakindent = true
33vim.o.undofile = true
34vim.o.ignorecase = true
35vim.o.smartcase = true
36vim.o.signcolumn = "yes"
37vim.o.updatetime = 250
38vim.o.timeoutlen = 600
39vim.o.splitright = true
40vim.o.splitbelow = true
41vim.o.inccommand = "split"
42vim.o.cursorline = true
43vim.o.swapfile = false
44vim.o.scrolloff = 10
45vim.o.hlsearch = true
46vim.o.list = true
47vim.o.wrap = false
48vim.o.tabstop = 4
49vim.o.shiftwidth = 4
50vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
51
52vim.g.mapleader = " "
53vim.g.maplocalleader = " "
54vim.g.have_nerd_font = true
55vim.o.winborder = "rounded"
56
57require("osmium").setup({
58 integrations = {
59 gitsigns = false,
60 telescope = true,
61 indent_blankline = false,
62 fff = false,
63 },
64 transparent_bg = false, -- whether to use a transparent background
65 show_end_of_buffer = false, -- whether to show the end of buffer
66})
67
68vim.cmd("colorscheme osmium")
69vim.cmd(":hi statusline guibg=NONE")
70
71local keymaps = function()
72 vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" })
73 vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
74 vim.keymap.set("n", "<leader>fb", "<CMD>Oil<CR>", { desc = "[F]ile [B]rowser" })
75 vim.keymap.set("n", "<leader>sf", "<CMD>Pick files<CR>", { desc = "[S]earch [F]iles" })
76 vim.keymap.set("n", "<leader>sg", "<CMD>Pick grep_live<CR>", { desc = "[S]earch by [G]rep" })
77 vim.keymap.set("n", "<leader>sr", "<CMD>Pick resume<CR>", { desc = "[S]earch [R]esume" })
78 vim.keymap.set({ "n", "v" }, "<leader>xe", require("nvim-emmet").wrap_with_abbreviation)
79 vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "[C]ode [A]ction" })
80 vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" })
81 vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "[G]oto [D]efinition" })
82 vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "[G]oto [R]eferences" })
83 vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" })
84 vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "[G]oto [I]mplementation" })
85 vim.keymap.set({ "i", "s" }, "<C-j>", function()
86 if vim.snippet.active({ direction = 1 }) then
87 vim.snippet.jump(1)
88 end
89 end, { desc = "Jump snippet next" })
90 vim.keymap.set({ "i", "s" }, "<C-k>", function()
91 if vim.snippet.active({ direction = -1 }) then
92 vim.snippet.jump(-1)
93 end
94 end, { desc = "Jump snippet back" })
95end
96
97require("mini.pick").setup({})
98
99vim.keymap.set("i", "<Tab>", function()
100 if vim.fn.pumvisible() == 1 then
101 return "<C-y>"
102 elseif vim.snippet.active({ direction = 1 }) then
103 return "<Cmd>lua vim.snippet.jump(1)<CR>"
104 else
105 return "<Tab>"
106 end
107end, { expr = true, desc = "Accept completion or jump snippet" })
108
109local ensure_installed = {
110 lsp = { "lua_ls", "emmet_ls", "oxlint", "tailwindcss" },
111 treesitter = { "lua", "typescript", "javascript", "tsx", "html", "css" },
112}
113
114local setup_blink = function()
115 require("blink.cmp").setup({
116 keymap = { preset = "default" },
117
118 appearance = {
119 -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
120 -- Adjusts spacing to ensure icons are aligned
121 nerd_font_variant = "mono",
122 },
123
124 -- (Default) Only show the documentation popup when manually triggered
125 completion = { documentation = { auto_show = true } },
126
127 -- Default list of enabled providers defined so that you can extend it
128 -- elsewhere in your config, without redefining it, due to `opts_extend`
129 sources = {
130 default = { "lsp", "path", "snippets", "buffer" },
131 },
132
133 -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
134 -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
135 -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
136 --
137 -- See the fuzzy documentation for more information
138 fuzzy = { implementation = "prefer_rust" },
139 })
140end
141
142local setup_conform = function()
143 require("conform").setup({
144 format_on_save = { timeout_ms = 500, lsp_fallback = true },
145 formatters_by_ft = {
146 lua = { "stylua" },
147 javascript = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
148 typescript = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
149 typescriptreact = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
150 javascriptreact = { "oxfmt", "prettierd", "prettier", stop_after_first = true },
151 json = { "prettierd", "prettier", stop_after_first = true },
152 html = { "prettierd", "prettier", stop_after_first = true },
153 css = { "prettierd", "prettier", stop_after_first = true },
154 },
155 })
156end
157
158local setup_oil = function()
159 ---@module 'oil'
160 ---@type oil.SetupOpts
161 local opts = {
162 default_file_explorer = true,
163 columns = {
164 "icon",
165 },
166 view_options = {
167 show_hidden = true,
168 is_hidden_file = function(name)
169 return name ~= ".." and vim.startswith(name, ".")
170 end,
171 },
172 }
173 require("oil").setup(opts)
174 require("mini.icons").setup({})
175end
176
177local setup_mason = function()
178 require("mason").setup()
179 require("mason-lspconfig").setup({
180 ensure_installed = ensure_installed.lsp,
181 })
182end
183
184-- hop
185local setup_hop = function()
186 local hop = require("hop")
187 local directions = require("hop.hint").HintDirection
188
189 local hopmap = function(key, direction, current_line_only)
190 vim.keymap.set("", key, function()
191 hop.hint_char1({
192 direction = direction,
193 current_line_only = current_line_only,
194 })
195 end, { remap = true })
196 end
197
198 hopmap("f", directions.AFTER_CURSOR, false)
199 hopmap("F", directions.BEFORE_CURSOR, false)
200 hopmap("t", directions.AFTER_CURSOR, true)
201 hopmap("T", directions.BEFORE_CURSOR, true)
202
203 hop.setup({
204 keys = "etovxqpdygfblzhckisuran",
205 })
206end
207--
208
209local setup_treesitter = function()
210 for _, lang in ipairs(ensure_installed.treesitter) do
211 vim.treesitter.language.add(lang)
212 end
213end
214
215local setup_typescript_tools = function()
216 require("typescript-tools").setup({})
217end
218
219-- Plugin setup
220setup_mason()
221setup_oil()
222setup_hop()
223setup_treesitter()
224setup_conform()
225setup_typescript_tools()
226setup_blink()
227keymaps()