vim.g.mapleader = ',' vim.g.maplocalleader = ',' vim.g.have_nerd_font = false vim.opt.termguicolors = true vim.opt.number = true vim.opt.relativenumber = true vim.opt.mouse = 'a' vim.opt.showmode = false vim.schedule(function() vim.opt.clipboard = 'unnamedplus' end) vim.opt.breakindent = true vim.opt.undofile = true vim.opt.ignorecase = true vim.opt.smartcase = true vim.opt.signcolumn = 'yes' vim.opt.updatetime = 250 vim.opt.timeoutlen = 300 vim.opt.splitright = true vim.opt.splitbelow = true vim.opt.list = true vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true vim.opt.softtabstop = 4 vim.opt.inccommand = 'split' vim.opt.cursorline = true vim.opt.scrolloff = 10 vim.keymap.set('n', '', 'nohlsearch') vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Highlight when yanking text', group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() vim.highlight.on_yank() end, }) local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not (vim.uv or vim.loop).fs_stat(lazypath) then local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', 'https://github.com/folke/lazy.nvim.git', lazypath } if vim.v.shell_error ~= 0 then error('Error cloning lazy.nvim:\n' .. out) end end vim.opt.rtp:prepend(lazypath) require('lazy').setup({ 'tpope/vim-sleuth', 'tinted-theming/tinted-vim', 'avm99963/vim-jjdescription', { 'lewis6991/gitsigns.nvim', opts = { signs = { add = { text = '+' }, change = { text = '~' }, delete = { text = '_' }, topdelete = { text = '‾' }, changedelete = { text = '~' } } }, }, { 'nicolasgb/jj.nvim', dependencies = { 'folke/snacks.nvim' }, config = function() require('jj').setup {} local cmd = require 'jj.cmd' vim.keymap.set('n', 'jl', cmd.log, { desc = 'JJ log' }) vim.keymap.set('n', 'js', cmd.status, { desc = 'JJ status' }) vim.keymap.set('n', 'jd', cmd.describe, { desc = 'JJ describe' }) vim.keymap.set('n', 'jn', cmd.new, { desc = 'JJ new' }) vim.keymap.set('n', 'je', cmd.edit, { desc = 'JJ edit' }) vim.keymap.set('n', 'ju', cmd.undo, { desc = 'JJ undo' }) vim.keymap.set('n', 'jq', cmd.squash, { desc = 'JJ squash' }) end, }, { 'folke/which-key.nvim', event = 'VimEnter', opts = { icons = { mappings = vim.g.have_nerd_font, keys = vim.g.have_nerd_font and {} or { Up = ' ', Down = ' ', Left = ' ', Right = ' ', C = ' ', M = ' ', D = ' ', S = ' ', CR = ' ', Esc = ' ', ScrollWheelDown = ' ', ScrollWheelUp = ' ', NL = ' ', BS = ' ', Space = ' ', Tab = ' ', F1 = '', F2 = '', F3 = '', F4 = '', F5 = '', F6 = '', F7 = '', F8 = '', F9 = '', F10 = '', F11 = '', F12 = '', }, }, spec = { { 'c', group = '[C]ode', mode = { 'n', 'x' } }, { 'd', group = '[D]ocument' }, { 'r', group = '[R]ename' }, { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, { 'j', group = '[J]ujutsu' }, }, }, }, { 'nvim-telescope/telescope.nvim', event = 'VimEnter', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make', cond = function() return vim.fn.executable 'make' == 1 end, }, { 'nvim-telescope/telescope-ui-select.nvim' }, { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, }, config = function() require('telescope').setup { extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown() } } } pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') local builtin = require 'telescope.builtin' vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '/', function() builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false }) end, { desc = '[/] Fuzzily search in current buffer' }) vim.keymap.set('n', 's/', function() builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files' } end, { desc = '[S]earch [/] in Open Files' }) vim.keymap.set('n', 'sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' }) end, }, { 'folke/lazydev.nvim', ft = 'lua', opts = { library = { { path = 'luvit-meta/library', words = { 'vim%.uv' } } } } }, { 'Bilal2453/luvit-meta', lazy = true }, { 'neovim/nvim-lspconfig', dependencies = { { 'williamboman/mason.nvim', config = true }, 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', { 'j-hui/fidget.nvim', opts = {} }, 'hrsh7th/cmp-nvim-lsp', }, config = function() vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) local map = function(keys, func, desc, mode) mode = mode or 'n' vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') map('rn', vim.lsp.buf.rename, '[R]e[n]ame') map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) vim.api.nvim_create_autocmd( { 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.document_highlight } ) vim.api.nvim_create_autocmd( { 'CursorMoved', 'CursorMovedI' }, { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.clear_references } ) vim.api.nvim_create_autocmd('LspDetach', { group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), callback = function(event2) vim.lsp.buf.clear_references() vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } end, }) end if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') end end, }) local capabilities = vim.tbl_deep_extend('force', vim.lsp.protocol.make_client_capabilities(), require('cmp_nvim_lsp').default_capabilities()) local servers = { nil_ls = { settings = { ['nil'] = { formatting = { command = { 'nixfmt' } }, }, }, }, lua_ls = { settings = { Lua = { completion = { callSnippet = 'Replace' } } }, }, } require('mason').setup() require('mason-tool-installer').setup { ensure_installed = { 'stylua' } } if vim.fn.executable 'nil' == 1 then local server = servers.nil_ls server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) vim.lsp.config('nil_ls', server) vim.lsp.enable 'nil_ls' end require('mason-lspconfig').setup { handlers = { function(server_name) local server = servers[server_name] or {} server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, }, } end, }, { 'stevearc/conform.nvim', event = { 'BufWritePre' }, cmd = { 'ConformInfo' }, keys = { { 'f', function() require('conform').format { async = true, lsp_format = 'fallback' } end, mode = '', desc = '[F]ormat buffer', }, }, opts = { notify_on_error = false, format_on_save = function(bufnr) local disable_filetypes = { c = true, cpp = true } return { timeout_ms = 500, lsp_format = disable_filetypes[vim.bo[bufnr].filetype] and 'never' or 'fallback' } end, formatters_by_ft = { lua = { 'stylua' }, nix = { 'nixfmt' }, }, }, }, { 'hrsh7th/nvim-cmp', event = 'InsertEnter', dependencies = { { 'L3MON4D3/LuaSnip', build = (vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0) and nil or 'make install_jsregexp' }, 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', }, config = function() local cmp = require 'cmp' local luasnip = require 'luasnip' luasnip.config.setup {} cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, completion = { completeopt = 'menu,menuone,noinsert' }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.confirm { select = true }, [''] = cmp.mapping.complete {}, [''] = cmp.mapping(function() if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() end end, { 'i', 's' }), [''] = cmp.mapping(function() if luasnip.locally_jumpable(-1) then luasnip.jump(-1) end end, { 'i', 's' }), }, sources = { { name = 'lazydev', group_index = 0 }, { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' } }, } end, }, { 'tinted-theming/tinted-vim', priority = 1000, init = function() vim.cmd.colorscheme 'base16-tomorrow-night' vim.cmd.hi 'Comment gui=none' end, }, { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, { 'echasnovski/mini.nvim', config = function() require('mini.ai').setup { n_lines = 500 } require('mini.surround').setup() local statusline = require 'mini.statusline' statusline.setup { use_icons = vim.g.have_nerd_font } statusline.section_location = function() return '%2l:%-2v' end end, }, { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', main = 'nvim-treesitter.configs', opts = { ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'nix', 'query', 'vim', 'vimdoc' }, auto_install = true, highlight = { enable = true, additional_vim_regex_highlighting = { 'ruby' } }, indent = { enable = true, disable = { 'ruby' } }, }, }, }, { ui = { icons = vim.g.have_nerd_font and {} or { cmd = '⌘', config = '🛠', event = '📅', ft = '📂', init = '⚙', keys = '🗝', plugin = '🔌', runtime = '💻', require = '🌙', source = '📄', start = '🚀', task = '📌', lazy = '💤 ', }, }, })