From 35aaf58a926e4a5329d88a85b500534dbc5e2b8e Mon Sep 17 00:00:00 2001 From: Devin Haska <2636402+wonderfulfrog@users.noreply.github.com> Date: Sat, 30 Dec 2023 17:47:22 -0800 Subject: [PATCH] Initial commit --- init.lua | 63 ++++++++++++++++++++++++++++++++++++++ lazy-lock.json | 23 ++++++++++++++ lua/keybinds.lua | 21 +++++++++++++ lua/plugins/commentary.lua | 3 ++ lua/plugins/completion.lua | 56 +++++++++++++++++++++++++++++++++ lua/plugins/fugitive.lua | 9 ++++++ lua/plugins/lsp-config.lua | 47 ++++++++++++++++++++++++++++ lua/plugins/lualine.lua | 12 ++++++++ lua/plugins/neo-tree.lua | 12 ++++++++ lua/plugins/surround.lua | 3 ++ lua/plugins/telescope.lua | 31 +++++++++++++++++++ lua/plugins/tokyonight.lua | 9 ++++++ lua/plugins/treesitter.lua | 18 +++++++++++ lua/plugins/trouble.lua | 7 +++++ 14 files changed, 314 insertions(+) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/keybinds.lua create mode 100644 lua/plugins/commentary.lua create mode 100644 lua/plugins/completion.lua create mode 100644 lua/plugins/fugitive.lua create mode 100644 lua/plugins/lsp-config.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/neo-tree.lua create mode 100644 lua/plugins/surround.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/tokyonight.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/trouble.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..708b323 --- /dev/null +++ b/init.lua @@ -0,0 +1,63 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +vim.opt.belloff = "all" +vim.opt.backspace = "2" +vim.opt.showcmd = true +vim.opt.laststatus = 2 +vim.opt.swapfile = false + +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.signcolumn = "yes" + +vim.opt.autoindent = true +vim.opt.smartindent = true +vim.opt.smarttab = true +vim.opt.expandtab = true +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.copyindent = true + +vim.opt.scrolloff = 2 +vim.opt.splitright = true +vim.opt.splitbelow = true +vim.opt.wrap = false +vim.opt.cursorline = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- Fix for yanking to system clipboard on Windows +if vim.fn.has('wsl') == 1 then + vim.g.clipboard = { + name = 'WslClipboard', + copy = { + ['+'] = 'clip.exe', + ['*'] = 'clip.exe', + }, + paste = { + ['+'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', + ['*'] = 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))', + }, + cache_enabled = 0, + } +end + +require("lazy").setup("plugins") +require("keybinds") + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..5e5948c --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,23 @@ +{ + "LuaSnip": { "branch": "master", "commit": "2463d687fe704b76eb0aa3bb34e95f69a5bb0362" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, + "mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, + "nui.nvim": { "branch": "main", "commit": "80445d015d2b5f9af0d9e8bce63d303bc86eda8a" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-lspconfig": { "branch": "master", "commit": "0d9e870d01894c592d7ea93cfe0fa451916d9a7f" }, + "nvim-treesitter": { "branch": "master", "commit": "e49f1e8ef3e8450a8446cb1f2bbb53c919f60b6d" }, + "nvim-treesitter-context": { "branch": "master", "commit": "652ec514d6ba8bc4a3c2de76c855fe668e2c7196" }, + "nvim-web-devicons": { "branch": "master", "commit": "808627b8d412b2a6b6fc6eed816fec3557198b01" }, + "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" }, + "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, + "vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" }, + "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" } +} \ No newline at end of file diff --git a/lua/keybinds.lua b/lua/keybinds.lua new file mode 100644 index 0000000..7c9a52f --- /dev/null +++ b/lua/keybinds.lua @@ -0,0 +1,21 @@ +vim.keymap.set("n", "", "", {}) +vim.keymap.set("n", "", "", {}) +vim.keymap.set("n", "", "", {}) +vim.keymap.set("n", "", "", {}) + +-- Move visual blocks around using J/K (up/down) +vim.keymap.set("v", "J", ":m '>+1gv=gv", {}) +vim.keymap.set("v", "K", ":m '<-2gv=gv", {}) + +-- Keep search terms in the middle of the screen +vim.keymap.set("n", "n", "nzzzv", {}) +vim.keymap.set("n", "N", "Nzzzv", {}) + +-- Paste without replacing clipboard contents +vim.keymap.set("x", "p", "\"_dP", {}) + +-- Yank into system clipboard +vim.keymap.set("n", "y", "\"+y", {}) + +-- Like ciw on the text under the cursor +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) diff --git a/lua/plugins/commentary.lua b/lua/plugins/commentary.lua new file mode 100644 index 0000000..4e85c75 --- /dev/null +++ b/lua/plugins/commentary.lua @@ -0,0 +1,3 @@ +return { + "tpope/vim-commentary" +} diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua new file mode 100644 index 0000000..e3f01ac --- /dev/null +++ b/lua/plugins/completion.lua @@ -0,0 +1,56 @@ +return { + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + + cmp.setup({ + -- Highlights the first result always + completion = { + completeopt = "menu,menuone,noinsert" + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping(function (fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i" }), + [""] = cmp.mapping(function (fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i" }), + [""] = cmp.mapping.confirm({ select = true }) + }), + + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end + }, + + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" } + }, { + { name = "buffer" } + }) + }) + end + }, + { + "hrsh7th/cmp-nvim-lsp" + }, + { + "L3MON4D3/LuaSnip" + } +} diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua new file mode 100644 index 0000000..a2e0c75 --- /dev/null +++ b/lua/plugins/fugitive.lua @@ -0,0 +1,9 @@ +return { + "tpope/vim-fugitive", + config = function () + vim.keymap.set("n", "gs", vim.cmd.Git) + vim.keymap.set("n", "gh", "diffget //2") + vim.keymap.set("n", "gl", "diffget //3") + end +} + diff --git a/lua/plugins/lsp-config.lua b/lua/plugins/lsp-config.lua new file mode 100644 index 0000000..bda5a51 --- /dev/null +++ b/lua/plugins/lsp-config.lua @@ -0,0 +1,47 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end + }, + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "tsserver", "eslint" } + }) + end + }, + { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require("lspconfig") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + lspconfig.lua_ls.setup({ + capabilities = capabilities + }) + + lspconfig.tsserver.setup({ + capabilities = capabilities + }) + + -- Runs :EslintFixAll when saving + lspconfig.eslint.setup({ + on_attach = function(_, bufnr) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + command = "EslintFixAll", + }) + end + }) + + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, {}) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) + vim.keymap.set('n', 'f', vim.lsp.buf.format, {}) + vim.keymap.set('n', 'vca', vim.lsp.buf.code_action, {}) + end + } +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..b368357 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,12 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup({ + options = { + icons_enabled = true, + theme = 'tokyonight' + } + }) + end +} diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..b0bbc1f --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,12 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = function() + vim.keymap.set("n", "nn", ":Neotree", {}) + end +} diff --git a/lua/plugins/surround.lua b/lua/plugins/surround.lua new file mode 100644 index 0000000..b5dd6ff --- /dev/null +++ b/lua/plugins/surround.lua @@ -0,0 +1,3 @@ +return { + "tpope/vim-surround" +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..29b009e --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,31 @@ +return { + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local builtin = require('telescope.builtin') + + vim.keymap.set('n', 'pp', builtin.git_files, {}) + vim.keymap.set('n', 'pf', builtin.find_files, {}) + vim.keymap.set('n', 'fh', builtin.help_tags, {}) + vim.keymap.set('n', 'ps', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) + end) + end + }, + { + "nvim-telescope/telescope-ui-select.nvim", + config = function() + require("telescope").setup { + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown {} + } + } + } + + require("telescope").load_extension("ui-select") + end + } +} diff --git a/lua/plugins/tokyonight.lua b/lua/plugins/tokyonight.lua new file mode 100644 index 0000000..6c6b53e --- /dev/null +++ b/lua/plugins/tokyonight.lua @@ -0,0 +1,9 @@ +return { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = {}, + config = function() + vim.cmd.colorscheme "tokyonight" + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..5bcb754 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,18 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local config = require("nvim-treesitter.configs") + config.setup({ + ensure_installed = { "lua", "javascript", "typescript", "tsx" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true } + }) + end + }, + { + "nvim-treesitter/nvim-treesitter-context" + } +} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua new file mode 100644 index 0000000..b1ad96d --- /dev/null +++ b/lua/plugins/trouble.lua @@ -0,0 +1,7 @@ +return { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + vim.keymap.set("n", "tt", ":TroubleToggle", {}) + end + }