local vim = vim local Plug = vim.fn['plug#'] local o = vim.opt local g = vim.g g.mapleader = ' ' g.maplocalleader = ' ' g.toggle_theme_icon = "  " g.have_nerd_font = true -- Line numbers o.number = true -- o.spell = true o.spelllang="en_us,es" -- Configure how new splits should be opened o.splitright = true o.splitbelow = true o.inccommand = 'split' -- Tabs o.shiftwidth = 2 o.tabstop = 2 o.undofile = true o.undodir = vim.fn.stdpath("data") .. "/undo//" -- https://www.reddit.com/r/neovim/comments/wlkq0e/neovim_configuration_to_backup_files_with/ o.backup = true o.backupdir = vim.fn.stdpath("data") .. "/backup//" -- o.clipboard = "unnamedplus" -- Statuscolumn -- Set sign column to be 4. -- So, if I have a new diff, It'll not feel weird, by the signcolumn expanding o.signcolumn = "yes:1" -- Statusline o.cmdheight = 0 o.laststatus = 3 -- Folds o.foldcolumn = "1" o.foldlevel = 99 o.foldlevelstart = 99 o.foldenable = true -- Enable break indent o.breakindent = true o.list = true o.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Scrolloff o.scrolloff = 15 -- Show which line your cursor is on o.cursorline = true -- Searching o.ignorecase = true o.smartcase = true o.pumblend = 10 -- Popup blend o.pumheight = 10 -- Maximum number of entries in a popup vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') local map = vim.keymap.set map('v', "y", '"+y') map('n', '', ':Treewalker Down', { noremap = true }) map('n', '', ':Treewalker Up', { noremap = true }) map('n', '', ':Treewalker Left', { noremap = true }) map('n', '', ':Treewalker Right', { noremap = true }) -- Diagnostic keymaps map('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) map('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) map('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) map('v', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) map('n', 'Q', 'gq') map('n', '.', ':CHADopen') vim.call('plug#begin') -- Style Plug 'folke/tokyonight.nvim' Plug 'olimorris/onedarkpro.nvim' Plug 'xiyaowong/transparent.nvim' Plug 'alexblackie/lunarised' Plug 'starryleo/starry-vim-colorschemes' -- lsp Plug('williamboman/mason.nvim') Plug('williamboman/mason-lspconfig.nvim') -- more lsp Plug('neovim/nvim-lspconfig') Plug('L3MON4D3/LuaSnip', { ['tag'] = 'v2.*', }) Plug 'marilari88/twoslash-queries.nvim' Plug 'neovim/nvim-lspconfig' -- auto complete Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/nvim-cmp' Plug 'zbirenbaum/copilot-cmp' -- copilot Plug 'L3MON4D3/LuaSnip' Plug 'saadparwaiz1/cmp_luasnip' -- useful stuff Plug 'echasnovski/mini.nvim' Plug 'zbirenbaum/copilot.lua' Plug 'ms-jpq/chadtree' Plug 'ryanoasis/vim-devicons' Plug 'jetzig-framework/zmpl.vim' -- tree sitter Plug 'nvim-treesitter/nvim-treesitter' Plug('aaronik/treewalker.nvim', { opts = { highlight = true } }) vim.call('plug#end') vim.cmd('set background=dark') vim.cmd('colorscheme nova') -- Better Around/Inside textobjects -- -- Examples: -- - va) - [V]isually select [A]round [)]paren -- - yinq - [Y]ank [I]nside [N]ext [']quote -- - ci' - [C]hange [I]nside [']quote require('mini.ai').setup { n_lines = 500 } -- Add/delete/replace surroundings (brackets, quotes, etc.) -- -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').setup() -- Simple and easy statusline. -- You could remove this setup call if you don't like it, -- and try some other statusline plugin local statusline = require 'mini.statusline' -- set use_icons to true if you have a Nerd Font statusline.setup { use_icons = vim.g.have_nerd_font } -- You can configure sections in the statusline by overriding their -- default behavior. For example, here we set the section for -- cursor location to LINE:COLUMN ---@diagnostic disable-next-line: duplicate-set-field statusline.section_location = function() return '%2l:%-2v' end -- ... and there is more! -- Check out: https://github.com/echasnovski/mini.nvim require('mini.pairs').setup() require('nvim-treesitter.configs').setup({ -- A list of parser names, or "all" (the listed parsers MUST always be installed) ensure_installed = {'bash', 'c', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc'}, sync_install = false, highlight = { enable = true, additional_vim_regex_highlighting = false, }, }) require("mason").setup() local lspconfig = require('lspconfig') lspconfig.hls.setup({}) lspconfig.zls.setup({ {cmd = '~/.zig/zls'} }) local lsp_cmds = vim.api.nvim_create_augroup('lsp_cmds', {clear = true}) vim.api.nvim_create_autocmd('LspAttach', { group = lsp_cmds, desc = 'LSP actions', callback = function() local bufmap = function(mode, lhs, rhs) vim.keymap.set(mode, lhs, rhs, {buffer = true}) end bufmap('n', 'K', 'lua vim.lsp.buf.hover()') bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') bufmap('n', 'gi', 'lua vim.lsp.buf.implementation()') bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') bufmap('n', 'gr', 'lua vim.lsp.buf.references()') bufmap('n', 'gs', 'lua vim.lsp.buf.signature_help()') bufmap('n', '', 'lua vim.lsp.buf.rename()') bufmap({'n', 'x'}, '', 'lua vim.lsp.buf.format({async = true})') bufmap('n', '', 'lua vim.lsp.buf.code_action()') bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') bufmap('n', '[d', 'lua vim.diagnostic.goto_prev()') bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') end }) require('mason-lspconfig').setup({ ensure_installed = {'hls'}, handlers = { function(server) lspconfig[server].setup({ capabilities = lsp_capabilities, }) end, } }) vim.opt.completeopt = {'menu', 'menuone', 'noselect'} require("copilot").setup({ suggestion = { enabled = false }, panel = { enabled = false }, }) require("copilot_cmp").setup() local cmp = require('cmp') local luasnip = require('luasnip') local select_opts = {behavior = cmp.SelectBehavior.Select} local has_words_before = function() if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and vim.api.nvim_buf_get_text(0, line-1, 0, line-1, col, {})[1]:match("^%s*$") == nil end -- See :help cmp-config cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end }, sources = { {name = 'path'}, {name = 'nvim_lsp', keyword_length = 3}, {name = 'buffer', keyword_length = 3}, {name = 'luasnip', keyword_length = 2}, {name = 'copilot', group_index = 2} }, window = { documentation = cmp.config.window.bordered() }, formatting = { fields = {'menu', 'abbr', 'kind'}, format = function(entry, item) local menu_icon = { nvim_lsp = 'λ', luasnip = '⋗', buffer = 'Ω', path = '🖫', } item.menu = menu_icon[entry.source.name] return item end, }, -- See :help cmp-mapping mapping = { [''] = cmp.mapping.select_prev_item(select_opts), [''] = cmp.mapping.select_next_item(select_opts), [''] = cmp.mapping.select_prev_item(select_opts), [''] = cmp.mapping.select_next_item(select_opts), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({select = false}), [''] = cmp.mapping(function(fallback) if luasnip.jumpable(1) then luasnip.jump(1) else fallback() end end, {'i', 's'}), [''] = cmp.mapping(function(fallback) if luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, {'i', 's'}), [''] = cmp.mapping(function(fallback) local col = vim.fn.col('.') - 1 if cmp.visible() and has_words_before() then cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) elseif cmp.visible() then cmp.select_next_item(select_opts) elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then fallback() else cmp.complete() end end, {'i', 's'}), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item(select_opts) else fallback() end end, {'i', 's'}), }, }) -- hyprland vim.api.nvim_create_autocmd("BufWritePost", { pattern = "hyprland.conf", callback = function() os.execute("hyprctl reload") vim.cmd.edit() end })