local vim = vim vim.pack.add({ { src = "https://github.com/stevearc/oil.nvim" }, { src = "https://github.com/nvim-mini/mini.icons" }, { src = "https://github.com/nvim-mini/mini.pick" }, { src = "https://github.com/lewis6991/gitsigns.nvim" }, { src = "https://github.com/windwp/nvim-autopairs" }, { src = "https://github.com/j-hui/fidget.nvim" }, { src = "https://github.com/folke/todo-comments.nvim" }, { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" }, -- { src = "https://github.com/numToStr/Comment.nvim" }, { src = "https://github.com/saghen/blink.cmp", version = "v1.9.1" }, { src = "https://github.com/rafamadriz/friendly-snippets" }, { src = "https://github.com/smoka7/hop.nvim" }, { src = "https://github.com/folke/trouble.nvim" }, -- themes { src = "https://github.com/vague-theme/vague.nvim" }, { src = "https://github.com/IroncladDev/osmium" }, { src = "https://github.com/serhez/teide.nvim" }, { src = "https://github.com/sainnhe/everforest" }, -- Mason / Lsp { src = "https://github.com/mason-org/mason.nvim.git" }, { src = "https://github.com/mason-org/mason-lspconfig.nvim.git" }, { src = "https://github.com/neovim/nvim-lspconfig.git" }, { src = "https://github.com/nvim-lua/plenary.nvim" }, { src = "https://github.com/olrtg/nvim-emmet" }, { src = "https://github.com/stevearc/conform.nvim" }, { src = "https://github.com/pmizio/typescript-tools.nvim" }, }) vim.o.number = true vim.o.relativenumber = true vim.o.mouse = "a" vim.o.showmode = false vim.o.clipboard = "unnamedplus" vim.o.breakindent = true vim.o.undofile = true vim.o.ignorecase = true vim.o.smartcase = true vim.o.signcolumn = "yes" vim.o.updatetime = 250 vim.o.timeoutlen = 600 vim.o.splitright = true vim.o.splitbelow = true vim.o.inccommand = "split" vim.o.cursorline = true vim.o.swapfile = false vim.o.scrolloff = 10 vim.o.hlsearch = true vim.o.list = true vim.o.wrap = false vim.o.tabstop = 4 vim.o.shiftwidth = 4 vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" } vim.g.mapleader = " " vim.g.maplocalleader = " " vim.g.have_nerd_font = true vim.o.winborder = "rounded" require("osmium").setup({ integrations = { gitsigns = false, telescope = true, indent_blankline = false, fff = false, }, transparent_bg = false, -- whether to use a transparent background show_end_of_buffer = false, -- whether to show the end of buffer }) vim.g.everforest_background = "hard" vim.g.everforest_better_performance = 1 vim.o.background = "dark" vim.cmd("colorscheme everforest") vim.cmd(":hi statusline guibg=NONE") local keymaps = function() vim.keymap.set("n", "e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" }) vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" }) vim.keymap.set("n", "fb", "Oil", { desc = "[F]ile [B]rowser" }) vim.keymap.set("n", "sf", "Pick files", { desc = "[S]earch [F]iles" }) vim.keymap.set("n", "sg", "Pick grep_live", { desc = "[S]earch by [G]rep" }) vim.keymap.set("n", "sr", "Pick resume", { desc = "[S]earch [R]esume" }) vim.keymap.set({ "n", "v" }, "xe", require("nvim-emmet").wrap_with_abbreviation) vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { desc = "[C]ode [A]ction" }) vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" }) vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "[G]oto [D]efinition" }) vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "[G]oto [R]eferences" }) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" }) vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "[G]oto [I]mplementation" }) vim.keymap.set({ "i", "s" }, "", function() if vim.snippet.active({ direction = 1 }) then vim.snippet.jump(1) end end, { desc = "Jump snippet next" }) vim.keymap.set({ "i", "s" }, "", function() if vim.snippet.active({ direction = -1 }) then vim.snippet.jump(-1) end end, { desc = "Jump snippet back" }) end require("mini.pick").setup({}) vim.keymap.set("i", "", function() if vim.fn.pumvisible() == 1 then return "" elseif vim.snippet.active({ direction = 1 }) then return "lua vim.snippet.jump(1)" else return "" end end, { expr = true, desc = "Accept completion or jump snippet" }) local ensure_installed = { lsp = { "lua_ls", "emmet_ls", "oxlint", "tailwindcss" }, treesitter = { "lua", "typescript", "javascript", "tsx", "html", "css", "svelte" }, } local setup_blink = function() require("blink.cmp").setup({ keymap = { preset = "default" }, appearance = { -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' -- Adjusts spacing to ensure icons are aligned nerd_font_variant = "mono", }, -- (Default) Only show the documentation popup when manually triggered completion = { documentation = { auto_show = true } }, -- Default list of enabled providers defined so that you can extend it -- elsewhere in your config, without redefining it, due to `opts_extend` sources = { default = { "lsp", "path", "snippets", "buffer" }, }, -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` -- -- See the fuzzy documentation for more information fuzzy = { implementation = "prefer_rust_with_warning" }, }) end local setup_conform = function() require("conform").setup({ format_on_save = { timeout_ms = 500, lsp_fallback = true }, formatters_by_ft = { lua = { "stylua" }, javascript = { "oxfmt", "prettierd", "prettier", stop_after_first = true }, typescript = { "oxfmt", "prettierd", "prettier", stop_after_first = true }, typescriptreact = { "oxfmt", "prettierd", "prettier", stop_after_first = true }, javascriptreact = { "oxfmt", "prettierd", "prettier", stop_after_first = true }, json = { "prettierd", "prettier", stop_after_first = true }, html = { "prettierd", "prettier", stop_after_first = true }, css = { "prettierd", "prettier", stop_after_first = true }, }, }) end local setup_oil = function() ---@module 'oil' ---@type oil.SetupOpts local opts = { default_file_explorer = true, columns = { "icon", }, view_options = { show_hidden = true, is_hidden_file = function(name) return name ~= ".." and vim.startswith(name, ".") end, }, } require("oil").setup(opts) require("mini.icons").setup({}) end -- hop local setup_hop = function() local hop = require("hop") local directions = require("hop.hint").HintDirection local hopmap = function(key, direction, current_line_only) vim.keymap.set("", key, function() hop.hint_char1({ direction = direction, current_line_only = current_line_only, }) end, { remap = true }) end hopmap("f", directions.AFTER_CURSOR, false) hopmap("F", directions.BEFORE_CURSOR, false) hopmap("t", directions.AFTER_CURSOR, true) hopmap("T", directions.BEFORE_CURSOR, true) hop.setup({ keys = "etovxqpdygfblzhckisuran", }) end -- local setup_treesitter = function() local parsers = ensure_installed.treesitter require("nvim-treesitter.install").ensure_installed(parsers) vim.api.nvim_create_autocmd("FileType", { callback = function(args) local buf, filetype = args.buf, args.match local language = vim.treesitter.language.get_lang(filetype) if not language then return end -- check if parser exists and load it if not vim.treesitter.language.add(language) then return end -- enables syntax highlighting and other treesitter features vim.treesitter.start(buf, language) -- enables treesitter based folds -- for more info on folds see `:help folds` -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' -- vim.wo.foldmethod = 'expr' -- enables treesitter based indentation vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end, }) end local setup_mason_and_lsp = function() require("mason").setup() local mason_lspconfig = require("mason-lspconfig") local lspconfig = require("lspconfig") local capabilities = require("blink.cmp").get_lsp_capabilities() mason_lspconfig.setup({ ensure_installed = ensure_installed.lsp, handlers = { -- default handler for most servers function(server_name) lspconfig[server_name].setup({ capabilities = capabilities, }) end, }, }) -- typescript-tools.nvim setup require("typescript-tools").setup({ capabilities = capabilities, settings = { expose_as_code_action = { "all" }, complete_function_calls = true, }, }) end -- Plugin setup setup_mason_and_lsp() setup_blink() setup_treesitter() setup_oil() setup_hop() setup_conform() keymaps() require("nvim-autopairs").setup({}) require("todo-comments").setup({ signs = false }) require("debug")