From 56bca305b2e994f8164630666fa9c3eabe324ccf Mon Sep 17 00:00:00 2001 From: devaine Date: Tue, 12 Nov 2024 21:40:50 -0600 Subject: [PATCH] added neovim config and basic README.md --- README.md | 8 ++- init.lua | 2 + lazy-lock.json | 28 +++++++++ lua/core/config/custom.lua | 22 +++++++ lua/core/lazy.lua | 36 +++++++++++ lua/core/plugins/autocomplete.lua | 45 ++++++++++++++ lua/core/plugins/colorscheme.lua | 11 ++++ lua/core/plugins/highlight.lua | 8 +++ lua/core/plugins/lsp.lua | 100 ++++++++++++++++++++++++++++++ lua/core/plugins/nvim-tree.lua | 12 ++++ lua/core/plugins/telescope.lua | 14 +++++ lua/core/plugins/tree-sitter.lua | 27 ++++++++ 12 files changed, 312 insertions(+), 1 deletion(-) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/core/config/custom.lua create mode 100644 lua/core/lazy.lua create mode 100644 lua/core/plugins/autocomplete.lua create mode 100644 lua/core/plugins/colorscheme.lua create mode 100644 lua/core/plugins/highlight.lua create mode 100644 lua/core/plugins/lsp.lua create mode 100644 lua/core/plugins/nvim-tree.lua create mode 100644 lua/core/plugins/telescope.lua create mode 100644 lua/core/plugins/tree-sitter.lua diff --git a/README.md b/README.md index 97d4d3c..45ee282 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # nvim -neovim config :> \ No newline at end of file +neovim config :> + +## Required Software to Install +* `ripgrep` - Treesitter +* `gcc` - Compiling LuaSnip +* `zip` and `unzip` + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..8fb0278 --- /dev/null +++ b/init.lua @@ -0,0 +1,2 @@ +require("core.lazy") +require("core.config.custom") -- Custom config diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..3cc596f --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,28 @@ +{ + "LuaSnip": { "branch": "master", "commit": "659c4479529a05cc9b05ef762639a09d366cc690" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "kanagawa.nvim": { "branch": "master", "commit": "ad3dddecd606746374ba4807324a08331dfca23c" }, + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "lua-async-await": { "branch": "main", "commit": "652d94df34e97abe2d4a689edbc4270e7ead1a98" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, + "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, + "nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" }, + "nvim-highlight-colors": { "branch": "main", "commit": "e967e2ba13fd4ca731b41d0e5cc1ac2edcd6e25e" }, + "nvim-java": { "branch": "main", "commit": "905013eb83c58bda992724b3ecbe20f60b58513f" }, + "nvim-java-core": { "branch": "main", "commit": "5b03dca22fee76524a89e1c2dc1d73a9f0b1a3bb" }, + "nvim-java-dap": { "branch": "main", "commit": "55f239532f7a3789d21ea68d1e795abc77484974" }, + "nvim-java-refactor": { "branch": "main", "commit": "ea1420fed5463c9cc976c2b4175f434b3646f0f7" }, + "nvim-java-test": { "branch": "main", "commit": "7f0f40e9c5b7eab5096d8bec6ac04251c6e81468" }, + "nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" }, + "nvim-tree.lua": { "branch": "master", "commit": "c7639482a1598f4756798df1b2d72f79fe5bb34f" }, + "nvim-treesitter": { "branch": "master", "commit": "7646c1c12a3121562aa87fd79aace48c728ac096" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "typescript-language-server": { "branch": "master", "commit": "184c60de3308621380469d6632bdff2e10f672fd" } +} diff --git a/lua/core/config/custom.lua b/lua/core/config/custom.lua new file mode 100644 index 0000000..6ba6a29 --- /dev/null +++ b/lua/core/config/custom.lua @@ -0,0 +1,22 @@ +local opt = vim.opt + +opt.guicursor = "" -- For indentation + +opt.relativenumber = true +opt.number = true + +opt.tabstop = 2 +opt.softtabstop = 2 +opt.shiftwidth = 2 +opt.smartindent = true + +opt.hlsearch = false +opt.incsearch = true + +opt.termguicolors = true + +vim.g.rust_recommended_style = 0 + +local setkb = vim.keymap.set + +setkb('n', '', '') diff --git a/lua/core/lazy.lua b/lua/core/lazy.lua new file mode 100644 index 0000000..f2ab52f --- /dev/null +++ b/lua/core/lazy.lua @@ -0,0 +1,36 @@ +-- Bootstrap lazy.nvim +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) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "core.plugins" }, + + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "kanagawa-dragon" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/core/plugins/autocomplete.lua b/lua/core/plugins/autocomplete.lua new file mode 100644 index 0000000..8ebaf49 --- /dev/null +++ b/lua/core/plugins/autocomplete.lua @@ -0,0 +1,45 @@ +-- https://github.com/hrsh7th/nvim-cmp +-- Basically a completion plugin for neovim +return { + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "L3MON4D3/LuaSnip", + build = "make install_jsregexp" + }, + "saadparwaiz1/cmp_luasnip", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' } + }), + formatting = { + format = require("nvim-highlight-colors").format + } + }) + end + }, + + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true + } +} diff --git a/lua/core/plugins/colorscheme.lua b/lua/core/plugins/colorscheme.lua new file mode 100644 index 0000000..73b6e65 --- /dev/null +++ b/lua/core/plugins/colorscheme.lua @@ -0,0 +1,11 @@ +return { + { + "rebelot/kanagawa.nvim", + lazy = false, + priority = 1000, + config = function() + -- loads colorscheme + vim.cmd([[colorscheme kanagawa-dragon]]) + end, + }, +} diff --git a/lua/core/plugins/highlight.lua b/lua/core/plugins/highlight.lua new file mode 100644 index 0000000..b47b33e --- /dev/null +++ b/lua/core/plugins/highlight.lua @@ -0,0 +1,8 @@ +-- For more information: https://github.com/brenoprata10/nvim-highlight-colors + +return { + "brenoprata10/nvim-highlight-colors", + config = function () + require("nvim-highlight-colors").setup({}) + end +} diff --git a/lua/core/plugins/lsp.lua b/lua/core/plugins/lsp.lua new file mode 100644 index 0000000..693ce79 --- /dev/null +++ b/lua/core/plugins/lsp.lua @@ -0,0 +1,100 @@ +return { + -- Java + -- For checksums: https://github.com/mfussenegger/nvim-jdtls/discussions/249#discussioncomment-3159367 + -- It's here first because it needs to have load before lspconfig apparently + { + "nvim-java/nvim-java", + dependencies = { + "neovim/nvim-lspconfig", + }, + config = function() + require("java").setup() + require("lspconfig").jdtls.setup({}) + end + }, + -- + + -- https://github.com/williamboman/mason.nvim?tab=readme-ov-file#configuration for more information + -- https://github.com/williamboman/mason-lspconfig.nvim?tab=readme-ov-file#setup for more info + { "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", -- https://github.com/neovim/nvim-lspconfig for more information + }, + opts = function() + require("mason").setup({ + registries = { + "github:nvim-java/mason-registry", + "github:mason-org/mason-registry" + } + }) + require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + "pylsp", + "clangd", + "bashls", + "ts_ls", + "eslint", + "cssls", + "html", + } + }) + + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local lspconfig = require("lspconfig") + + -- LSP Servers + + lspconfig.lua_ls.setup { + capabilities = capabilities + } + + -- FOR bashls + -- Make sure to install 'shellcheck', :MasonInstall shellcheck + -- Make sure to install 'shfmt', :MasonInstall shfmt + + lspconfig.bashls.setup { + capabilities = capabilities + } + + lspconfig.pylsp.setup {} + + lspconfig.clangd.setup{ + cmd = { "clangd", "--background-index", "--clang-tidy", "--log=verbose", "--query-driver=/usr/bin/c++", "--suggest-missing-includes", "--all-scopes-completion", "--completion-style=detailed" }, + init_options = { + fallback_flags = { "-std=c++17" }, + }, + capabilities = capabilities + } + + lspconfig.ts_ls.setup { + capabilities = capabilities, + init_options = { + preferences = { + disableSuggestions = true + } + } + } + + lspconfig.eslint.setup { + capabilities = capabilities + + } + + lspconfig.html.setup { + capabilities = capabilities, + } + + + lspconfig.cssls.setup { + capabilities = capabilities + } + end + }, + + -- Javascript and/or Typescript + { + "typescript-language-server/typescript-language-server" + } +} diff --git a/lua/core/plugins/nvim-tree.lua b/lua/core/plugins/nvim-tree.lua new file mode 100644 index 0000000..90ee458 --- /dev/null +++ b/lua/core/plugins/nvim-tree.lua @@ -0,0 +1,12 @@ +-- https://github.com/nvim-tree/nvim-tree.lua?tab=readme-ov-file -- For more information +return { + "nvim-tree/nvim-tree.lua", + version = "*", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("nvim-tree").setup {} + end, +} diff --git a/lua/core/plugins/telescope.lua b/lua/core/plugins/telescope.lua new file mode 100644 index 0000000..f6906be --- /dev/null +++ b/lua/core/plugins/telescope.lua @@ -0,0 +1,14 @@ +-- For more information on the arguements, visit: https://www.lazyvim.org/extras/editor/telescope#telescopenvim OR for more information on telescope, visit: https://github.com/nvim-telescope/telescope.nvim +return { + 'nvim-telescope/telescope.nvim', tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' }, + cmd = "Telescope", + keys = { + { "//", "Telescope", desc = "Start" }, + + { "pp", "Telescope find_files", desc = "File Picker" }, + { ";;", "Telescope buffers", desc = "Buffer Picker" }, + { "..", "Telescope treesitter", desc = "Treesitter" }, + { "[[", "Telescop live_grep", desc = "Grep" } + } +} diff --git a/lua/core/plugins/tree-sitter.lua b/lua/core/plugins/tree-sitter.lua new file mode 100644 index 0000000..ef46b9a --- /dev/null +++ b/lua/core/plugins/tree-sitter.lua @@ -0,0 +1,27 @@ +-- https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#language-parsers for language parsers +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "BufRead", + config = function() + local configs = require("nvim-treesitter.configs") + configs.setup({ + ensure_installed = { "lua", "cpp", "java", "javascript", "bash", "python", "typescript", "css", "html", "jsdoc" }, + sync_install = true, + auto_intsall = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = false + }, + ident = { enable = true }, + autopairs = { + enable = true + } + }) + end, + keys = { + { "mm", "NvimTreeToggle", desc = "Toggle Tree"} + } +} + +