------------------------------------------------------------------------------- -- locals ------------------------------------------------------------------------------- local homedir = vim.fn.expand("$HOME") ------------------------------------------------------------------------------- -- Lazy.nvim install ------------------------------------------------------------------------------- local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath, }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end vim.opt.rtp:prepend(lazypath) ------------------------------------------------------------------------------- -- Vim options ------------------------------------------------------------------------------- vim.g.mapleader = "," vim.g.maplocalleader = "\\" vim.opt.exrc = false vim.opt.secure = true vim.opt.number = true vim.opt.mouse = "" vim.opt.spelllang = "en_us" vim.opt.foldmethod = "indent" vim.opt.foldlevel = 99 vim.opt.clipboard = "unnamedplus" vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.softtabstop = 4 vim.opt.expandtab = false vim.opt.smartindent = true vim.opt.list = true vim.opt.ignorecase = true vim.opt.infercase = true vim.opt.smartcase = true vim.opt.listchars = { tab = "⏵ ", trail = "." } -- , eol = "$" vim.opt.rulerformat = "%l,%v" vim.opt.colorcolumn = "75,79" vim.opt.undofile = true vim.opt.undodir = homedir .. "/.undodir" vim.opt.lazyredraw = false vim.opt.textwidth = 78 vim.opt.endoffile = true ------------------------------------------------------------------------------- -- Auto commands ------------------------------------------------------------------------------- vim.api.nvim_create_autocmd({ "FileType" }, { pattern = { "*.lua" }, callback = function() vim.keymap.set("n", "", "w!lua %") end, }) ------------------------------------------------------------------------------- -- Key mappings ------------------------------------------------------------------------------- vim.keymap.set("i", "jk", "") ------------------------------------------------------------------------------- -- Plugins ------------------------------------------------------------------------------- local plugins = { "neovim/nvim-lspconfig", "neovim/nvim-lspconfig", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "hrsh7th/cmp-cmdline", "hrsh7th/nvim-cmp", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", "tpope/vim-commentary", "tpope/vim-surround", "tpope/vim-repeat", "vim-airline/vim-airline", "ctrlpvim/ctrlp.vim", "jiangmiao/auto-pairs", "nelstrom/vim-visual-star-search", "dhruvasagar/vim-table-mode", "nvim-treesitter/nvim-treesitter", } ------------------------------------------------------------------------------- -- Load Lazy ------------------------------------------------------------------------------- require("lazy").setup(plugins, { spec = { -- import your plugins { import = "plugins" }, }, -- Configure any other settings here. See the documentation for more details. -- colorscheme that will be used when installing plugins. install = { colorscheme = { "habamax" } }, -- automatically check for plugin updates checker = { enabled = true }, }) ------------------------------------------------------------------------------- -- Load LSP ------------------------------------------------------------------------------- require("lspconfig").lua_ls.setup({ on_attach = function() -- add code if needed end, on_init = function(_client) -- add code if needed end, }) ------------------------------------------------------------------------------- -- Load nvim-cmp ------------------------------------------------------------------------------- vim.opt.completeopt = { "menu", "menuone", "noselect" } local cmp = require("cmp") cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) require("luasnip").lsp_expand(args.body) end, }, window = { -- completion = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm({ select = true }), }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" }, }, { { name = "buffer" }, }), }) local capabilities = require("cmp_nvim_lsp").default_capabilities() -- Add for each lsp server you've enabled. require("lspconfig")["lua_ls"].setup { capabilities = capabilities, } -- Load LuaSnip require("luasnip.loaders.from_snipmate").lazy_load()