diff options
| author | Wayne-Cole <77279425+Wacky404@users.noreply.github.com> | 2023-12-02 13:49:34 -0600 |
|---|---|---|
| committer | Wayne-Cole <77279425+Wacky404@users.noreply.github.com> | 2023-12-02 13:49:34 -0600 |
| commit | 98f5ab658c18cae2c36d0d08df471b6b1f03faa1 (patch) | |
| tree | e7eaca203511b64ac65a5522498eed85dcc89840 | |
| download | wackys-dev-env-98f5ab658c18cae2c36d0d08df471b6b1f03faa1.tar.xz wackys-dev-env-98f5ab658c18cae2c36d0d08df471b6b1f03faa1.zip | |
intial config commit
| -rw-r--r-- | .config/nvim/init.lua | 15 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/core/colorscheme.lua | 5 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/core/keymaps.lua | 76 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/core/options.lua | 41 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins-setup.lua | 128 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/autopairs.lua | 30 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/comment.lua | 6 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/gitsigns.lua | 8 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/lsp/lspconfig.lua | 95 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/lsp/lspsaga.lua | 19 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/lsp/mason.lua | 54 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/lsp/null-ls.lua | 46 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/lualine.lua | 6 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/nvim-cmp.lua | 51 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/nvim-tree.lua | 63 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/telescope.lua | 25 | ||||
| -rw-r--r-- | .config/nvim/lua/cole/plugins/treesitter.lua | 34 | ||||
| -rw-r--r-- | .config/nvim/plugin/packer_compiled.lua | 266 |
18 files changed, 968 insertions, 0 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..008957e --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,15 @@ +require("cole.plugins-setup") +require("cole.core.options") +require("cole.core.keymaps") +require("cole.core.colorscheme") +require("cole.plugins.comment") +require("cole.plugins.nvim-tree") +require("cole.plugins.lualine") +require("cole.plugins.telescope") +require("cole.plugins.nvim-cmp") +require("cole.plugins.lsp.mason") +require("cole.plugins.lsp.lspsaga") +require("cole.plugins.lsp.null-ls") +require("cole.plugins.autopairs") +require("cole.plugins.treesitter") +require("cole.plugins.gitsigns") diff --git a/.config/nvim/lua/cole/core/colorscheme.lua b/.config/nvim/lua/cole/core/colorscheme.lua new file mode 100644 index 0000000..d642d67 --- /dev/null +++ b/.config/nvim/lua/cole/core/colorscheme.lua @@ -0,0 +1,5 @@ +local status, _ = pcall(vim.cmd, "colorscheme nordic") +if not status then + print("Color Scheme not Found") + return +end diff --git a/.config/nvim/lua/cole/core/keymaps.lua b/.config/nvim/lua/cole/core/keymaps.lua new file mode 100644 index 0000000..5ea6d9f --- /dev/null +++ b/.config/nvim/lua/cole/core/keymaps.lua @@ -0,0 +1,76 @@ +-- set leader key to space +vim.g.mapleader = " " + +local keymap = vim.keymap -- for conciseness + +--------------------- +-- General Keymaps +--------------------- + +-- use jk to exit insert mode +keymap.set("i", "jk", "<ESC>") + +-- clear search highlights +keymap.set("n", "<leader>ch", ":nohl<CR>") + +-- delete single character without copying into register +keymap.set("n", "x", '"_x') + +-- increment/decrement numbers +keymap.set("n", "<leader>+", "<C-a>") -- increment +keymap.set("n", "<leader>-", "<C-x>") -- decrement + +-- window management +keymap.set("n", "<leader>sv", "<C-w>v") -- split window vertically +keymap.set("n", "<leader>sh", "<C-w>s") -- split window horizontally +keymap.set("n", "<leader>se", "<C-w>=") -- make split windows equal width & height +keymap.set("n", "<leader>sx", ":close<CR>") -- close current split window + +-- terminal +vim.keymap.set("t", "<esc>", [[<C-\><C-n>]], opts) + +-- toggle-terminal +keymap.set("n", "<leader>tt", ":ToggleTerm dir=git_dir<CR>") +---------------------- +-- keymap.set("n", "<leader>to", ":tabnew<CR>") -- open new tab +-- keymap.set("n", "<leader>tx", ":tabclose<CR>") -- close current tab +-- keymap.set("n", "<leader>tn", ":tabn<CR>") -- go to next tab +-- keymap.set("n", "<leader>tp", ":tabp<CR>") -- go to previous tab +---------------------- + +---------------------- +-- Plugin Keybinds +---------------------- + +-- vim-maximizer +keymap.set("n", "<leader>sm", ":MaximizerToggle<CR>") -- toggle split window maximization + +-- nvim-tree +keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>") -- toggle file explorer + +-- telescope +keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>") -- find files within current working directory, respects .gitignore +keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>") -- find string in current working directory as you type +keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>") -- find string under cursor in current working directory +keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>") -- list open buffers in current neovim instance +keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>") -- list available help tags + +-- telescope git commands +keymap.set("n", "<leader>gc", "<cmd>Telescope git_commits<cr>") -- list all git commits (use <cr> to checkout) ["gc" for git commits] +keymap.set("n", "<leader>gfc", "<cmd>Telescope git_bcommits<cr>") -- list git commits for current file/buffer (use <cr> to checkout) ["gfc" for git file commits] +keymap.set("n", "<leader>gb", "<cmd>Telescope git_branches<cr>") -- list git branches (use <cr> to checkout) ["gb" for git branch] +keymap.set("n", "<leader>gs", "<cmd>Telescope git_status<cr>") -- list current changes per file with diff preview ["gs" for git status] + +-- restart lsp server +keymap.set("n", "<leader>rs", ":LspRestart<CR>") -- mapping to restart lsp if necessary + +-- DAP : basic commands +-------------------------- +--keymap.set("n", "<leader>con", ":lua require('dap').continue()<CR>") -- continue the debugger +--keymap.set("n", "<leader>so", ":lua require('dap').step_over()<CR>") -- step over a line +--keymap.set("n", "<leader>si", ":lua require('dap').step_into()<CR>") -- step into a line +--keymap.set("n", "<leader>ol", ":lua require('dap').step_out()<CR>") -- step out of a line +--keymap.set("n", "<leader>tb", ":lua require'dap'.toggle_breakpoint()<CR>)") -- toggle a breakpoint for debugger +--keymap.set("n", "<leader>b", ":lua require('dap').set_breakpoint()<CR>") -- make a breakpoint at a line +--keymap.set("n", "<leader>rl", ":lua require('dap').run_last()<CR>") -- run the last action +-------------------------- diff --git a/.config/nvim/lua/cole/core/options.lua b/.config/nvim/lua/cole/core/options.lua new file mode 100644 index 0000000..7675260 --- /dev/null +++ b/.config/nvim/lua/cole/core/options.lua @@ -0,0 +1,41 @@ +local opt = vim.opt -- for conciseness + +-- line numbers +opt.relativenumber = true +opt.number = true + +-- tabs & indentation +opt.tabstop = 4 +opt.shiftwidth = 4 +opt.expandtab = true +opt.autoindent = true + +-- line wrapping +opt.wrap = false + +--search settings +opt.ignorecase = true +opt.smartcase = true + +-- cursor line +opt.cursorline = true + +-- appearance +opt.termguicolors = true +opt.background = "dark" +opt.signcolumn = "yes" + +-- backspace +opt.backspace = "indent,eol,start" + +--clipboard +opt.clipboard:append("unnamedplus") + +-- split windows +opt.splitright = true +opt.splitbelow = true + +opt.iskeyword:append("-") + +-- fold method +opt.foldmethod = "manual" diff --git a/.config/nvim/lua/cole/plugins-setup.lua b/.config/nvim/lua/cole/plugins-setup.lua new file mode 100644 index 0000000..69a4294 --- /dev/null +++ b/.config/nvim/lua/cole/plugins-setup.lua @@ -0,0 +1,128 @@ +-- auto install packer if not installed +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) + vim.cmd([[packadd packer.nvim]]) + return true + end + return false +end +local packer_bootstrap = ensure_packer() -- true if packer was just installed + +-- autocommand that reloads neovim and installs/updates/removes plugins +-- when file is saved +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins-setup.lua source <afile> | PackerSync + augroup end +]]) + +-- import packer safely +local status, packer = pcall(require, "packer") +if not status then + return +end + +-- add list of plugins to install +return packer.startup(function(use) + -- packer can manage itself + use("wbthomason/packer.nvim") + + use("nvim-lua/plenary.nvim") -- lua functions that many plugins use + + -- Color Scheme is here!!! + use("AlexvZyl/nordic.nvim") -- preferred colorscheme + + use("christoomey/vim-tmux-navigator") -- tmux & split window navigation + + use("szw/vim-maximizer") -- maximizes and restores current window + + -- essential plugins + use("tpope/vim-surround") -- add, delete, change surroundings (it's awesome) + use("inkarkat/vim-ReplaceWithRegister") -- replace with register contents using motion (gr + motion) + + -- commenting with gc + use("numToStr/Comment.nvim") + + -- file explorer + use("nvim-tree/nvim-tree.lua") + + -- vs-code like icons + use("nvim-tree/nvim-web-devicons") + + -- statusline + use("nvim-lualine/lualine.nvim") + + -- fuzzy finding w/ telescope + use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- dependency for better sorting performance + use({ "nvim-telescope/telescope.nvim", branch = "0.1.x" }) -- fuzzy finder + + -- autocompletion + use("hrsh7th/nvim-cmp") -- completion plugin + use("hrsh7th/cmp-buffer") -- source for text in buffer + use("hrsh7th/cmp-path") -- source for file system paths + + -- snippets + use("L3MON4D3/LuaSnip") -- snippet engine + use("saadparwaiz1/cmp_luasnip") -- for autocompletion + use("rafamadriz/friendly-snippets") -- useful snippets + + -- managing & installing lsp servers, linters & formatters + use("williamboman/mason.nvim") -- in charge of managing lsp servers, linters & formatters + use("williamboman/mason-lspconfig.nvim") -- bridges gap b/w mason & lspconfig + + -- configuring lsp servers + use("neovim/nvim-lspconfig") -- easily configure language servers + use("hrsh7th/cmp-nvim-lsp") -- for autocompletion + use({ + "glepnir/lspsaga.nvim", + branch = "main", + requires = { + { "nvim-tree/nvim-web-devicons" }, + { "nvim-treesitter/nvim-treesitter" }, + }, + }) -- enhanced lsp uis + + -- vs-code like icons for autocompletion + use("onsails/lspkind.nvim") + + -- treesitter configuration + use({ + "nvim-treesitter/nvim-treesitter", + run = function() + local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) + ts_update() + end, + }) + + -- auto closing + use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc... + use({ "windwp/nvim-ts-autotag", after = "nvim-treesitter" }) -- autoclose tags + + -- git integration + use("lewis6991/gitsigns.nvim") -- show line modifications on left hand side + + -- formatting & linting + use("jose-elias-alvarez/null-ls.nvim") -- configure formatters and linters + use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason and null-ls + + -- toggle terminal + use({ + "akinsho/toggleterm.nvim", + tag = "*", + config = function() + require("toggleterm").setup({ + size = 15, + direction = "horizontal", + autochdir = false, + }) + end, + }) + + if packer_bootstrap then + require("packer").sync() + end +end) diff --git a/.config/nvim/lua/cole/plugins/autopairs.lua b/.config/nvim/lua/cole/plugins/autopairs.lua new file mode 100644 index 0000000..19890bb --- /dev/null +++ b/.config/nvim/lua/cole/plugins/autopairs.lua @@ -0,0 +1,30 @@ +-- import nvim-autopairs safely +local autopairs_setup, autopairs = pcall(require, "nvim-autopairs") +if not autopairs_setup then + return +end + +-- configure autopairs +autopairs.setup({ + check_ts = true, -- enable treesitter + ts_config = { + lua = { "string" }, -- don't add pairs in lua string treesitter nodes + javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes + java = false, -- don't check treesitter on java + }, +}) + +-- import nvim-autopairs completion functionality safely +local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") +if not cmp_autopairs_setup then + return +end + +-- import nvim-cmp plugin safely (completions plugin) +local cmp_setup, cmp = pcall(require, "cmp") +if not cmp_setup then + return +end + +-- make autopairs and completion work together +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) diff --git a/.config/nvim/lua/cole/plugins/comment.lua b/.config/nvim/lua/cole/plugins/comment.lua new file mode 100644 index 0000000..80a2672 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/comment.lua @@ -0,0 +1,6 @@ +local setup, comment = pcall(require, "Comment") +if not setup then + return +end + +comment.setup() diff --git a/.config/nvim/lua/cole/plugins/gitsigns.lua b/.config/nvim/lua/cole/plugins/gitsigns.lua new file mode 100644 index 0000000..22f7ba6 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/gitsigns.lua @@ -0,0 +1,8 @@ +-- import gitsigns plugin safely +local setup, gitsigns = pcall(require, "gitsigns") +if not setup then + return +end + +-- configure/enable gitsigns +gitsigns.setup() diff --git a/.config/nvim/lua/cole/plugins/lsp/lspconfig.lua b/.config/nvim/lua/cole/plugins/lsp/lspconfig.lua new file mode 100644 index 0000000..622b3b4 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/lsp/lspconfig.lua @@ -0,0 +1,95 @@ +-- import lspconfig plugin safely +local lspconfig_status, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status then + return +end + +-- import cmp-nvim-lsp plugin safely +local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not cmp_nvim_lsp_status then + return +end + +local keymap = vim.keymap -- for conciseness + +-- enable keybinds only for when lsp server available +local on_attach = function(client, bufnr) + -- keybind options + local opts = { noremap = true, silent = true, buffer = bufnr } + + -- set keybinds + keymap.set("n", "gf", "<cmd>Lspsaga lsp_finder<CR>", opts) -- show definition, references + keymap.set("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts) -- got to declaration + keymap.set("n", "gd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window + keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation + keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions + keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename + keymap.set("n", "<leader>D", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line + keymap.set("n", "<leader>d", "<cmd>Lspsaga show_cursor_diagnostics<CR>", opts) -- show diagnostics for cursor + keymap.set("n", "[d", "<cmd>Lspsaga diagnostic_jump_prev<CR>", opts) -- jump to previous diagnostic in buffer + keymap.set("n", "]d", "<cmd>Lspsaga diagnostic_jump_next<CR>", opts) -- jump to next diagnostic in buffer + keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", opts) -- show documentation for what is under cursor + keymap.set("n", "<leader>o", "<cmd>LSoutlineToggle<CR>", opts) -- see outline on right hand side +end + +-- used to enable autocompletion (assign to every lsp server config) +local capabilities = cmp_nvim_lsp.default_capabilities() + +-- Change the Diagnostic symbols in the sign column (gutter) +-- (not in youtube nvim video) +local signs = { Error = " ", Warn = " ", Hint = "ﴞ ", Info = " " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end + +-- configure cpp server +lspconfig["clangd"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + +-- configure cmake server +lspconfig["cmake"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + +-- configure arduino server +lspconfig["arduino_language_server"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + +-- configure latex language server +lspconfig["ltex"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + +-- configure python server +lspconfig["jedi_language_server"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) + +-- configure lua server (with special settings) +lspconfig["lua_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { -- custom settings for lua + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + workspace = { + -- make language server aware of runtime files + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +}) diff --git a/.config/nvim/lua/cole/plugins/lsp/lspsaga.lua b/.config/nvim/lua/cole/plugins/lsp/lspsaga.lua new file mode 100644 index 0000000..90f5d57 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/lsp/lspsaga.lua @@ -0,0 +1,19 @@ +-- import lspsaga safely +local saga_status, saga = pcall(require, "lspsaga") +if not saga_status then + return +end + +saga.setup({ + -- keybinds for navigation in lspsaga window + scroll_preview = { scroll_down = "<C-f>", scroll_up = "<C-b>" }, + -- use enter to open file with definition preview + definition = { + edit = "<CR>", + }, + ui = { + colors = { + normal_bg = "#022746", + }, + }, +}) diff --git a/.config/nvim/lua/cole/plugins/lsp/mason.lua b/.config/nvim/lua/cole/plugins/lsp/mason.lua new file mode 100644 index 0000000..1b097b1 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/lsp/mason.lua @@ -0,0 +1,54 @@ +-- import mason plugin safely +local mason_status, mason = pcall(require, "mason") +if not mason_status then + return +end + +-- import mason-lspconfig plugin safely +local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig") +if not mason_lspconfig_status then + return +end + +-- import mason-null-ls plugin safely +local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls") +if not mason_null_ls_status then + return +end + +-- enable mason and configure icons +mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, +}) + +mason_lspconfig.setup({ + -- list of servers for mason to install + ensure_installed = { + "lua_ls", + "clangd", + "cmake", + "arduino_language_server", + "ltex", + "jedi_language_server", + }, + -- auto-install configured servers (with lspconfig) + automatic_installation = true, -- not the same as ensure_installed +}) + +mason_null_ls.setup({ + -- list of formatters & linters & adapters for mason to install + ensure_installed = { + "black", -- python code formatter + "stylua", -- lua formatter + "clang-format", -- cpp formatter + "cpplint", -- cpp linter + }, + -- auto-install configured formatters & linters (with null-ls) + automatic_installation = true, +}) diff --git a/.config/nvim/lua/cole/plugins/lsp/null-ls.lua b/.config/nvim/lua/cole/plugins/lsp/null-ls.lua new file mode 100644 index 0000000..f6e2d9d --- /dev/null +++ b/.config/nvim/lua/cole/plugins/lsp/null-ls.lua @@ -0,0 +1,46 @@ +-- import null-ls plugin safely +local setup, null_ls = pcall(require, "null-ls") +if not setup then + return +end + +-- for conciseness +local formatting = null_ls.builtins.formatting -- to setup formatters +local diagnostics = null_ls.builtins.diagnostics -- to setup linters + +-- to setup format on save +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +-- configure null_ls +null_ls.setup({ + -- setup formatters & linters + sources = { + -- might install pyre as linter + -- turned off cpplint + formatting.black, -- python formatter + formatting.stylua, -- lua formatter + formatting.clang_format, -- cpp formatter + diagnostics.pyre, -- python linter + diagnostics.cpplint, -- cpp linter + }, + + -- configure format on save + on_attach = function(current_client, bufnr) + if current_client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ + filter = function(client) + -- only use null-ls for formatting instead of lsp server + return client.name == "null-ls" + end, + bufnr = bufnr, + }) + end, + }) + end + end, +}) diff --git a/.config/nvim/lua/cole/plugins/lualine.lua b/.config/nvim/lua/cole/plugins/lualine.lua new file mode 100644 index 0000000..37718da --- /dev/null +++ b/.config/nvim/lua/cole/plugins/lualine.lua @@ -0,0 +1,6 @@ +local status, lualine = pcall(require, "lualine") +if not status then + return +end + +lualine.setup() diff --git a/.config/nvim/lua/cole/plugins/nvim-cmp.lua b/.config/nvim/lua/cole/plugins/nvim-cmp.lua new file mode 100644 index 0000000..075ea60 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/nvim-cmp.lua @@ -0,0 +1,51 @@ +local cmp_status, cmp = pcall(require, "cmp") +if not cmp_status then + return +end + +local luasnip_status, luasnip = pcall(require, "luasnip") +if not luasnip_status then + return +end + +-- import lspkind plugin safely +local lspkind_status, lspkind = pcall(require, "lspkind") +if not lspkind_status then + return +end + +-- load vs-code like snippets from plugins (e.g. friendly-snippets) +require("luasnip/loaders/from_vscode").lazy_load() + +vim.opt.completeopt = "menu,menuone,noselect" + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + ["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion + ["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion + ["<C-b>"] = cmp.mapping.scroll_docs(-4), + ["<C-f>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions + ["<C-e>"] = cmp.mapping.abort(), -- close completion window + ["<CR>"] = cmp.mapping.confirm({ select = false }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- lsp + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + -- configure lspkind for vs-code like icons + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, +}) diff --git a/.config/nvim/lua/cole/plugins/nvim-tree.lua b/.config/nvim/lua/cole/plugins/nvim-tree.lua new file mode 100644 index 0000000..fea9a85 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/nvim-tree.lua @@ -0,0 +1,63 @@ +local setup, nvimtree = pcall(require, "nvim-tree") +if not setup then + return +end + +-- recommended settings from nvim-tree documentation +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- change color for arrows in tree to light blue +vim.cmd([[ highlight NvimTreeIndentMarker guifg=#3FC5FF ]]) + +-- configure nvim-tree +nvimtree.setup({ + -- change folder arrow icons + renderer = { + icons = { + glyphs = { + folder = { + arrow_closed = "", -- arrow when folder is closed + arrow_open = "", -- arrow when folder is open + }, + }, + }, + }, + -- disable window_picker for + -- explorer to work well with + -- window splits + actions = { + open_file = { + window_picker = { + enable = false, + }, + }, + }, + -- git = { + -- ignore = false, + -- }, +}) + +-- open nvim-tree on setup + +local function open_nvim_tree(data) + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" + + -- buffer is a directory + local directory = vim.fn.isdirectory(data.file) == 1 + + if not no_name and not directory then + return + end + + -- change to the directory + if directory then + vim.cmd.cd(data.file) + end + + -- open the tree + require("nvim-tree.api").tree.open() +end + +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) diff --git a/.config/nvim/lua/cole/plugins/telescope.lua b/.config/nvim/lua/cole/plugins/telescope.lua new file mode 100644 index 0000000..fea5ece --- /dev/null +++ b/.config/nvim/lua/cole/plugins/telescope.lua @@ -0,0 +1,25 @@ +local telescope_setup, telescope = pcall(require, "telescope") +if not telescope_setup then + return +end + +local actions_setup, actions = pcall(require, "telescope.actions") +if not actions_setup then + return +end + +-- configure telescope +telescope.setup({ + -- configure custom mappings + defaults = { + mappings = { + i = { + ["<C-k>"] = actions.move_selection_previous, -- move to prev result + ["<C-j>"] = actions.move_selection_next, -- move to next result + ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist, -- send selected to quickfixlist + }, + }, + }, +}) + +telescope.load_extension("fzf") diff --git a/.config/nvim/lua/cole/plugins/treesitter.lua b/.config/nvim/lua/cole/plugins/treesitter.lua new file mode 100644 index 0000000..b99c0f3 --- /dev/null +++ b/.config/nvim/lua/cole/plugins/treesitter.lua @@ -0,0 +1,34 @@ +-- import nvim-treesitter plugin safely +local status, treesitter = pcall(require, "nvim-treesitter.configs") +if not status then + return +end + +-- configure treesitter +treesitter.setup({ + -- enable syntax highlighting + highlight = { + enable = true, + }, + -- enable indentation + indent = { enable = true }, + -- enable autotagging (w/ nvim-ts-autotag plugin) + autotag = { enable = true }, + -- ensure these language parsers are installed + ensure_installed = { + "arduino", + "c", + "cpp", + "latex", + "python", + "json", + "markdown", + "markdown_inline", + "bash", + "lua", + "vim", + "gitignore", + }, + -- auto install above language parsers + auto_install = true, +}) diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua new file mode 100644 index 0000000..91fd5c8 --- /dev/null +++ b/.config/nvim/plugin/packer_compiled.lua @@ -0,0 +1,266 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +local time +local profile_info +local should_profile = false +if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end +else + time = function(chunk, start) end +end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end + + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/Users/cole/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?.lua;/Users/cole/.cache/nvim/packer_hererocks/2.1.1700008891/share/lua/5.1/?/init.lua;/Users/cole/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?.lua;/Users/cole/.cache/nvim/packer_hererocks/2.1.1700008891/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/Users/cole/.cache/nvim/packer_hererocks/2.1.1700008891/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + ["Comment.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/Comment.nvim", + url = "https://github.com/numToStr/Comment.nvim" + }, + LuaSnip = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["cmp-buffer"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-path"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + ["friendly-snippets"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, + ["gitsigns.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", + url = "https://github.com/lewis6991/gitsigns.nvim" + }, + ["lspkind.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/lspkind.nvim", + url = "https://github.com/onsails/lspkind.nvim" + }, + ["lspsaga.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/lspsaga.nvim", + url = "https://github.com/glepnir/lspsaga.nvim" + }, + ["lualine.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/lualine.nvim", + url = "https://github.com/nvim-lualine/lualine.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason-null-ls.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/mason-null-ls.nvim", + url = "https://github.com/jayp0521/mason-null-ls.nvim" + }, + ["mason.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + ["nordic.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/nordic.nvim", + url = "https://github.com/AlexvZyl/nordic.nvim" + }, + ["null-ls.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/null-ls.nvim", + url = "https://github.com/jose-elias-alvarez/null-ls.nvim" + }, + ["nvim-autopairs"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/nvim-autopairs", + url = "https://github.com/windwp/nvim-autopairs" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-tree.lua"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + url = "https://github.com/nvim-tree/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-ts-autotag"] = { + load_after = {}, + loaded = true, + needs_bufread = false, + path = "/Users/cole/.local/share/nvim/site/pack/packer/opt/nvim-ts-autotag", + url = "https://github.com/windwp/nvim-ts-autotag" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/nvim-tree/nvim-web-devicons" + }, + ["packer.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["telescope-fzf-native.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim", + url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["toggleterm.nvim"] = { + config = { "\27LJ\2\nf\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\1K\0\1\0\1\0\3\tsize\3\15\14autochdir\1\14direction\15horizontal\nsetup\15toggleterm\frequire\0" }, + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/toggleterm.nvim", + url = "https://github.com/akinsho/toggleterm.nvim" + }, + ["vim-ReplaceWithRegister"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/vim-ReplaceWithRegister", + url = "https://github.com/inkarkat/vim-ReplaceWithRegister" + }, + ["vim-maximizer"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/vim-maximizer", + url = "https://github.com/szw/vim-maximizer" + }, + ["vim-surround"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/vim-surround", + url = "https://github.com/tpope/vim-surround" + }, + ["vim-tmux-navigator"] = { + loaded = true, + path = "/Users/cole/.local/share/nvim/site/pack/packer/start/vim-tmux-navigator", + url = "https://github.com/christoomey/vim-tmux-navigator" + } +} + +time([[Defining packer_plugins]], false) +-- Config for: toggleterm.nvim +time([[Config for toggleterm.nvim]], true) +try_loadstring("\27LJ\2\nf\0\0\3\0\4\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0005\2\3\0B\0\2\1K\0\1\0\1\0\3\tsize\3\15\14autochdir\1\14direction\15horizontal\nsetup\15toggleterm\frequire\0", "config", "toggleterm.nvim") +time([[Config for toggleterm.nvim]], false) +-- Load plugins in order defined by `after` +time([[Sequenced loading]], true) +vim.cmd [[ packadd nvim-treesitter ]] +vim.cmd [[ packadd nvim-ts-autotag ]] +time([[Sequenced loading]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = false + +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end |
