diff --git a/nvim/init.lua b/nvim/init.lua index b4731486..ad43eb93 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,5 +1,5 @@ -require("./mappings") -require("./lazy") +-- Leader +vim.g.mapleader = " " -- Guard (Linters + Formatters) vim.g.guard_config = { @@ -10,3 +10,61 @@ vim.g.guard_config = { -- Sync system clipboard and neovim register vim.opt.clipboard = { "unnamedplus" } + +-- Save undo history +vim.opt.undofile = true +-- +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Modules -- + +-- Lazy = Package Manager -- +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) + +require("lazy").setup("plugins") + +vim.cmd("colorscheme everblush") + +-- Mappings + +-- Save -- +vim.keymap.set("n", "", "w") + +-- Split navigation -- +vim.keymap.set("n", "", "h") +vim.keymap.set("n", "", "j") +vim.keymap.set("n", "", "k") +vim.keymap.set("n", "", "l") + +-- Buffers -- +vim.keymap.set("n", "x", "bd") + +-- Telescope Mappings -- +local builtin = require("telescope.builtin") +vim.keymap.set("n", "ff", builtin.find_files, { desc = "Telescope find files" }) +vim.keymap.set("n", "fw", builtin.live_grep, { desc = "Telescope live grep" }) + +-- Neo Tree -- +vim.keymap.set("n", "", " Neotree toggle ") +vim.keymap.set("n", "e", " Neotree focus ") + +-- LSP -- +vim.keymap.set("n", "gd", vim.lsp.buf.definition) +vim.keymap.set("n", "ca", vim.lsp.buf.code_action) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 8829430d..62f2d910 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,13 +1,17 @@ { + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "everblush": { "branch": "main", "commit": "9a0e695fdd57b340d3ba2b72406e3ca519029f25" }, "guard-collection": { "branch": "main", "commit": "06da4a065b974bbedf1a5535232c90a3526f8a43" }, "guard.nvim": { "branch": "main", "commit": "bdbc43dadd530b0058708723db76e705a4542063" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, + "nvim-cmp": { "branch": "main", "commit": "d3a3056204e1a9dbb7c7fe36c114dc43b681768c" }, "nvim-lspconfig": { "branch": "master", "commit": "38da5bbe1eaab2394056109e48c7e195bdb8fdfe" }, "nvim-treesitter": { "branch": "master", "commit": "0179a89656b4ce395a4487c07ae385b8425524ae" }, "nvim-web-devicons": { "branch": "master", "commit": "f0267921c845c42685968401bc49aa65e18d3e09" }, "nvim-window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, - "telescope.nvim": { "branch": "master", "commit": "74ce793a60759e3db0d265174f137fb627430355" } + "telescope.nvim": { "branch": "master", "commit": "74ce793a60759e3db0d265174f137fb627430355" }, + "vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" } } \ No newline at end of file diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index 48c2ce3a..f539040f 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -1,4 +1,34 @@ return { + { "Everblush/nvim", name = "everblush" }, + { "hrsh7th/vim-vsnip" }, + { "hrsh7th/cmp-nvim-lsp" }, + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + cmp.setup({ + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + 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 = "vsnip" }, + }, { + { name = "buffer" }, + }), + }) + end, + }, + { "nvimdev/guard.nvim", -- Builtin configuration, optional @@ -23,7 +53,7 @@ return { local configs = require("nvim-treesitter.configs") configs.setup({ - ensure_installed = { "lua", "javascript", "typescript", "html" }, + ensure_installed = { "lua", "javascript", "typescript", "html", "tsx" }, sync_install = false, highlight = { enable = true }, indent = { enable = true }, @@ -42,6 +72,12 @@ return { "s1n7ax/nvim-window-picker", version = "2.*", config = function() + require("neo-tree").setup({ + update_focused_file = { + enable = true, + }, + }) + require("window-picker").setup({ filter_rules = { include_current_win = false, @@ -66,8 +102,13 @@ return { }, { "neovim/nvim-lspconfig", + dependencies = { "hrsh7th/cmp-nvim-lsp" }, config = function() - require("lspconfig").lua_ls.setup({ + local lsp = require("lspconfig") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + lsp.lua_ls.setup({ + capabilities = capabilities, settings = { Lua = { diagnostics = { globals = { "vim", "require" } }, @@ -78,6 +119,10 @@ return { }, }, }) + + lsp.vtsls.setup({ + capabilities = capabilities, + }) end, }, }