From 8b4bacceb6a014beca677b16a01eddd526a4cd87 Mon Sep 17 00:00:00 2001 From: Arkaprabha Chakraborty Date: Wed, 27 Mar 2024 23:52:39 +0530 Subject: [PATCH] Merge commits till d9dba624a9502b0b172523dad30dc080e4170811 from dev to master --- README.md | 34 +-- init.lua | 24 +- install.sh | 36 --- lazy-lock.json | 32 +++ lua/buffer-tabs.lua | 13 -- lua/colorschemes.lua | 210 ------------------ lua/completions.lua | 62 ------ lua/file-tree.lua | 73 ------ lua/keybinds.lua | 49 ---- lua/lsp-format.lua | 33 --- lua/mappings.lua | 59 +++++ lua/plugins.lua | 151 +++++++------ lua/setup/cmp.lua | 126 +++++++++++ lua/setup/colorscheme.lua | 7 + .../gitsigns.lua} | 0 lua/setup/gui.lua | 8 + lua/{statusline.lua => setup/lualine.lua} | 0 lua/setup/null-ls.lua | 35 +++ lua/setup/nvim-cmp.lua | 93 ++++++++ .../nvim-lspconfig.lua} | 0 lua/{fuzzy-finder.lua => setup/telescope.lua} | 14 +- .../treesitter.lua} | 0 lua/terminal.lua | 16 -- lua/transparency.lua | 33 --- lua/visible-indents.lua | 12 - 25 files changed, 461 insertions(+), 659 deletions(-) delete mode 100755 install.sh create mode 100644 lazy-lock.json delete mode 100644 lua/buffer-tabs.lua delete mode 100644 lua/colorschemes.lua delete mode 100644 lua/completions.lua delete mode 100644 lua/file-tree.lua delete mode 100644 lua/keybinds.lua delete mode 100644 lua/lsp-format.lua create mode 100644 lua/mappings.lua create mode 100644 lua/setup/cmp.lua create mode 100644 lua/setup/colorscheme.lua rename lua/{git-integration.lua => setup/gitsigns.lua} (100%) create mode 100644 lua/setup/gui.lua rename lua/{statusline.lua => setup/lualine.lua} (100%) create mode 100644 lua/setup/null-ls.lua create mode 100644 lua/setup/nvim-cmp.lua rename lua/{lsp-config.lua => setup/nvim-lspconfig.lua} (100%) rename lua/{fuzzy-finder.lua => setup/telescope.lua} (65%) rename lua/{syntax-highlight.lua => setup/treesitter.lua} (100%) delete mode 100644 lua/terminal.lua delete mode 100644 lua/transparency.lua delete mode 100644 lua/visible-indents.lua diff --git a/README.md b/README.md index b1823f7..8552475 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,20 @@ ![neolite.png](blob/neolite.png) -# Updates -- A minimal configuration has been pushed to the [minimal](https://github.com/arkorty/neolite/tree/minimal) branch. - # About Neolite is a fast and lightweight configuration of Neovim. For the uninitiated, Neovim is a terminal based text editor which can be extended using the [Lua](https://www.lua.org/about.html) scripting language. Neovim out-of-the-box doesn't come with a lot of features, but it is highly extensible. It comes with native LSP support (lets your IDE do all that auto-completion magic). Vim has been in use since forever, so you don't have to worry about the project going stale anytime soon. -You also have the added benefit of becoming a true Vim chad once you start using Neovim instead of that pathetic web browser (ahem.. VS Code) disguised as an IDE. +You also have the added benefit of becoming a true Vim chad once you start using Neovim instead of some web browser (ahem.. VS Code) disguised as an IDE. # Dependencies -- [cURL](https://github.com/curl/curl) - [Git](https://github.com/git/git) - [Neovim](https://github.com/neovim/neovim) +- [Make](https://www.gnu.org/software/make) # Optional Dependencies - [npm](https://github.com/npm/cli) -- [Lazygit](https://github.com/jesseduffield/lazygit) - -# Quick Start - -Once you have all the dependencies sorted, run the command below and we'll take care of the rest. - -``` -curl -sLf https://raw.githubusercontent.com/arkorty/neolite/master/install.sh | bash -``` - -# Screenshots - -### File Tree & Active Buffer - -![file-tree.png](blob/file-tree.png) - -### Fuzzy Finder - -![fuzzy-finder.png](blob/fuzzy-finder.png) - -### Terminal & Lazygit - -![lazygit.png](blob/lazygit.png) - -### Live Grep - -![live-grep.png](blob/live-grep.png) # License diff --git a/init.lua b/init.lua index 48099ce..f81824c 100644 --- a/init.lua +++ b/init.lua @@ -1,16 +1,12 @@ require("plugins") require("options") -require("keybinds") -require("statusline") -require("completions") -require("colorschemes") -require("file-tree") -require("terminal") -require("buffer-tabs") -require("fuzzy-finder") -require("syntax-highlight") -require("lsp-config") -require("lsp-format") -require("transparency") -require("visible-indents") -require("git-integration") +require("mappings") +require("setup.lualine") +require("setup.cmp") +require("setup.telescope") +require("setup.treesitter") +require("setup.nvim-lspconfig") +require("setup.null-ls") +require("setup.gitsigns") +require("setup.colorscheme") +require("setup.gui") diff --git a/install.sh b/install.sh deleted file mode 100755 index 8c75640..0000000 --- a/install.sh +++ /dev/null @@ -1,36 +0,0 @@ -# Project: Neolite -# Script: install.sh -# License: MIT -# Author: Arkaprabha Chakraborty -# Edited: 11-03-23 -# -# Copyright (C) 2023 Arkaprabha Chakraborty - -#!/bin/bash - -if command -v nvim >/dev/null 2>&1 ; then - : -else - echo "No installation of Neovim was found" - echo "Quitting now..." - exit 127 -fi - -NPMDP="" -if command -v npm >/dev/null 2>&1 ; then - NPMDP="pyright prettier" -else - echo "No installation of npm was found" - echo "Some lsp packages will not be installed automatically" -fi - - -[ -d "$HOME/.local/share/nvim/site/pack/packer" ] && rm -rf $HOME/.local/share/nvim/site/pack/packer -git clone --depth 1 https://github.com/wbthomason/packer.nvim $HOME/.local/share/nvim/site/pack/packer/start/packer.nvim - -[ -d "$HOME/.config/nvim" ] && mv $HOME/.config/nvim $HOME/.config/nvim-$(date "+%F-%T").bak - -mkdir -p $HOME/.config/nvim && git clone --depth 1 https://github.com/arkorty/neolite.git $HOME/.config/nvim - -nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerSync" -nvim +TSUpdate "+MasonInstall stylua rustfmt black clang-format $NPMDP" diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..9332c62 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,32 @@ +{ + "LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, + "bufferline.nvim": { "branch": "main", "commit": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "copilot.vim": { "branch": "release", "commit": "9484e35cf222e9360e05450622a884f95c662c4c" }, + "dressing.nvim": { "branch": "master", "commit": "18e5beb3845f085b6a33c24112b37988f3f93c06" }, + "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, + "gitsigns.nvim": { "branch": "main", "commit": "078041e9d060a386b0c9d3a8c7a7b019a35d3fb0" }, + "gruvbox.nvim": { "branch": "main", "commit": "6e4027ae957cddf7b193adfaec4a8f9e03b4555f" }, + "kanagawa.nvim": { "branch": "master", "commit": "bfa818c7bf6259152f1d89cf9fbfba3554c93695" }, + "lazy.nvim": { "branch": "main", "commit": "e888d5b64c34bc41f7ef2e8850a5e67e4b3e2731" }, + "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, + "lualine.nvim": { "branch": "master", "commit": "b5e8bb642138f787a2c1c5aedc2a78cb2cebbd67" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "9dfcf2036c223920826140f0151d929a43f9eceb" }, + "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, + "melange-nvim": { "branch": "master", "commit": "ec15b091304580f1d37e711c3a54bc828b09e255" }, + "nightfox.nvim": { "branch": "main", "commit": "e352a32e0f54feb2550ebdab815ae8f7f26ed63b" }, + "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "nvim-cmp": { "branch": "main", "commit": "97dc716fc914c46577a4f254035ebef1aa72558a" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, + "nvim-lspconfig": { "branch": "master", "commit": "6e5c78ebc9936ca74add66bda22c566f951b6ee5" }, + "nvim-treesitter": { "branch": "master", "commit": "07a404570f3d912afdfe92bbf74ff55886293369" }, + "nvim-web-devicons": { "branch": "master", "commit": "3ee60deaa539360518eaab93a6c701fe9f4d82ef" }, + "plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" }, + "rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" }, + "toggleterm.nvim": { "branch": "main", "commit": "193786e0371e3286d3bc9aa0079da1cd41beaa62" } +} \ No newline at end of file diff --git a/lua/buffer-tabs.lua b/lua/buffer-tabs.lua deleted file mode 100644 index c4ce633..0000000 --- a/lua/buffer-tabs.lua +++ /dev/null @@ -1,13 +0,0 @@ --- set termguicolors to enable highlight groups -vim.opt.termguicolors = true - -local ok, bufferline = pcall(require, "bufferline") -if not ok then - return -end - -bufferline.setup({ - options = { - mode = "tabs", -- set to "buffers" to only show buffers instead - }, -}) diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua deleted file mode 100644 index 7e0df72..0000000 --- a/lua/colorschemes.lua +++ /dev/null @@ -1,210 +0,0 @@ -local colorscheme = "catppuccin" -- Set colorscheme { gruvbox, onedark, catppuccin, nord, dracula, alduin } - -if colorscheme == "onedark" then - -- Onedark Default Configuration - local ok, onedark = pcall(require, "onedark") - if not ok then - return - end - onedark.setup({ - -- Main options -- - style = "darker", -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light' - transparent = false, -- Show/hide background - term_colors = true, -- Change terminal color as per the selected theme style - ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden - cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu - -- toggle theme style --- - toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example 'ts' - toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between - -- Change code style --- - -- Options are italic, bold, underline, none - -- You can configure multiple style with comma seperated, For e.g., keywords = 'italic,bold' - code_style = { - comments = "italic", - keywords = "none", - functions = "none", - strings = "none", - variables = "none", - }, - -- Lualine options -- - lualine = { - transparent = false, -- lualine center bar transparency - }, - -- Custom Highlights -- - colors = {}, -- Override default colors - highlights = {}, -- Override highlight groups - -- Plugins Config -- - diagnostics = { - darker = true, -- darker colors for diagnostic - undercurl = true, -- use undercurl instead of underline for diagnostics - background = true, -- use background color for virtual text - }, - }) - - -- Load One Dark - onedark.load() -end - -if colorscheme == "catppuccin" then - -- Catppuccin - local ok, catppuccin = pcall(require, "catppuccin") - if not ok then - return - end - catppuccin.setup({ - flavour = "macchiato", -- latte, frappe, macchiato, mocha - background = { - -- :h background - light = "latte", - dark = "mocha", - }, - transparent_background = false, - show_end_of_buffer = false, -- show the '~' characters after the end of buffers - term_colors = false, - dim_inactive = { - enabled = false, - shade = "dark", - percentage = 0.15, - }, - no_italic = false, -- Force no italic - no_bold = false, -- Force no bold - styles = { - comments = { "italic" }, - conditionals = { "italic" }, - loops = {}, - functions = {}, - keywords = {}, - strings = {}, - variables = {}, - numbers = {}, - booleans = {}, - properties = {}, - types = {}, - operators = {}, - }, - color_overrides = {}, - custom_highlights = {}, - integrations = { - cmp = true, - gitsigns = true, - nvimtree = true, - telescope = true, - notify = false, - mini = false, - -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) - }, - }) - - -- Load Catppuccin - vim.cmd.colorscheme("catppuccin") -end - -if colorscheme == "gruvbox" then - -- setup must be called before loading the colorscheme - -- Default options: - local ok, gruvbox = pcall(require, "gruvbox") - if not ok then - return - end - - gruvbox.setup({ - undercurl = true, - underline = true, - bold = true, - italic = { - strings = true, - comments = true, - operators = false, - folds = true, - }, - strikethrough = true, - invert_selection = false, - invert_signs = false, - invert_tabline = false, - invert_intend_guides = false, - inverse = true, -- invert background for search, diffs, statuslines and errors - contrast = "", -- can be "hard", "soft" or empty string - palette_overrides = {}, - overrides = {}, - dim_inactive = false, - transparent_mode = false, - }) - - -- Load Gruvbox - vim.o.background = "dark" -- or "light" for light mode - vim.cmd([[colorscheme gruvbox]]) -end - -if colorscheme == "nord" then - local ok = pcall(require, "nord") - if not ok then - return - end - - vim.cmd([[colorscheme nord]]) -end - -if colorscheme == "everforest" then - local ok = pcall(require, "nord") - if not ok then - return - end - - vim.cmd([[colorscheme everforest]]) -end - -if colorscheme == "alduin" then - vim.cmd([[colorscheme alduin]]) -end - -if colorscheme == "dracula" then - local ok, dracula = pcall(require, "dracula") - if not ok then - return - end - - dracula.setup({ - -- customize dracula color palette - colors = { - bg = "#282A36", - fg = "#F8F8F2", - selection = "#44475A", - comment = "#6272A4", - red = "#FF5555", - orange = "#FFB86C", - yellow = "#F1FA8C", - green = "#50fa7b", - purple = "#BD93F9", - cyan = "#8BE9FD", - pink = "#FF79C6", - bright_red = "#FF6E6E", - bright_green = "#69FF94", - bright_yellow = "#FFFFA5", - bright_blue = "#D6ACFF", - bright_magenta = "#FF92DF", - bright_cyan = "#A4FFFF", - bright_white = "#FFFFFF", - menu = "#21222C", - visual = "#3E4452", - gutter_fg = "#4B5263", - nontext = "#3B4048", - }, - -- show the '~' characters after the end of buffers - show_end_of_buffer = true, -- default false - -- use transparent background - transparent_bg = true, -- default false - -- set custom lualine background color - lualine_bg_color = "#44475a", -- default nil - -- set italic comment - italic_comment = true, -- default false - -- overrides the default highlights see `:h synIDattr` - overrides = { - -- Examples - -- NonText = { fg = dracula.colors().white }, -- set NonText fg to white - -- NvimTreeIndentMarker = { link = "NonText" }, -- link to NonText highlight - -- Nothing = {} -- clear highlight of Nothing - }, - }) - - vim.cmd([[colorscheme dracula]]) -end diff --git a/lua/completions.lua b/lua/completions.lua deleted file mode 100644 index 8fef3ff..0000000 --- a/lua/completions.lua +++ /dev/null @@ -1,62 +0,0 @@ -local ok, cmp = pcall(require, "cmp") -if not ok then - return -end - -local luasnip_ok, luasnip = pcall(require, "luasnip") -if not luasnip_ok then - return -end - -local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode") -if not luasnip_vscode_ok then - return -end - -luasnip_vscode.lazy_load() - -cmp.setup({ - view = { - --entries = { name = "custom", selection_order = "near_cursor" }, - }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) -- For `luasnip` users. - end, - }, - mapping = { - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.confirm(), - }, - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }, - confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - experimental = { - ghost_text = false, - }, - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - local lk_ok, lspkind = pcall(require, "lspkind") - if not lk_ok then - return - end - local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) - local strings = vim.split(kind.kind, "%s", { trimempty = true }) - kind.kind = " " .. (strings[1] or "") .. " " - kind.menu = " (" .. (strings[2] or "") .. ")" - - return kind - end, - }, -}) diff --git a/lua/file-tree.lua b/lua/file-tree.lua deleted file mode 100644 index d183d0c..0000000 --- a/lua/file-tree.lua +++ /dev/null @@ -1,73 +0,0 @@ --- disable netrw -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 - --- set termguicolors to enable highlight groups -vim.opt.termguicolors = true - -local ok, nvim_tree = pcall(require, "nvim-tree") -if not ok then - return -end - --- file tree options -nvim_tree.setup({ - sort_by = "case_sensitive", - update_cwd = true, - renderer = { - group_empty = true, - root_folder_label = ":t", - indent_width = 2, - }, - filters = { - dotfiles = false, - git_clean = false, - no_buffer = false, - exclude = {}, - }, - actions = { - open_file = { - resize_window = true, - }, - }, - update_focused_file = { - enable = true, - update_cwd = false, - ignore_list = {}, - }, - git = { - enable = true, - ignore = false, - show_on_dirs = true, - show_on_open_dirs = true, - timeout = 200, - }, -}) - --- open file tree at startup -local function open_nvim_tree(data) - -- buffer is a directory - local directory = vim.fn.isdirectory(data.file) == 1 - - if not directory then - return - end - - -- create a new, empty buffer - vim.cmd.enew() - - -- wipe the directory buffer - vim.cmd.bw(data.buf) - - -- change to the directory - vim.cmd.cd(data.file) - - -- open the tree - local api_ok, api = pcall(require, "nvim-tree.api") - if not api_ok then - return - end - api.tree.open() -end - -vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) diff --git a/lua/keybinds.lua b/lua/keybinds.lua deleted file mode 100644 index f7aa2fd..0000000 --- a/lua/keybinds.lua +++ /dev/null @@ -1,49 +0,0 @@ -local opts = { noremap = true, silent = true } - ---Local term_opts = { silent = true } -local bind = vim.api.nvim_set_keymap -local set = vim.keymap.set - --- Bind a leader key -bind("", ";", "", opts) -- undo any previous bind -vim.g.mapleader = ";" -vim.g.maplocalleader = ";" - --- Modes --- Normal Mode = 'n', --- Insert Mode = 'i', --- Visual Mode = 'v', --- Visual Block Mode = 'x', --- Terminal Mode = 't', --- Command Mode = 'c', - --- Normal mode -- --- Nvim tree -bind("n", "", ":NvimTreeToggle", opts) - --- Fuzzy finder -local telescope_status_ok, telescope = pcall(require, "telescope.builtin") -if telescope_status_ok then - set("n", "ff", telescope.find_files, {}) - set("n", "fg", telescope.live_grep, {}) - set("n", "fb", telescope.buffers, {}) - set("n", "fh", telescope.help_tags, {}) -end - --- Better tabs -bind("n", "", ":tabnew", opts) -bind("n", "", ":tabclose", opts) -bind("n", "", ":tabprev", opts) -bind("n", "", ":tabnext", opts) - --- Better window navigation -bind("n", "", "h", opts) -bind("n", "", "j", opts) -bind("n", "", "k", opts) -bind("n", "", "l", opts) - --- Resize with arrows -bind("n", "", ":resize -2", opts) -bind("n", "", ":resize +2", opts) -bind("n", "", ":vertical resize -2", opts) -bind("n", "", ":vertical resize +2", opts) diff --git a/lua/lsp-format.lua b/lua/lsp-format.lua deleted file mode 100644 index 139f311..0000000 --- a/lua/lsp-format.lua +++ /dev/null @@ -1,33 +0,0 @@ -local ok, null_ls = pcall(require, "null-ls") -if not ok then - return -end - -local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -require("null-ls").setup({ - sources = { - null_ls.builtins.formatting.rustfmt, - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.black, - null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.clang_format, - }, - -- you can reuse a shared lspconfig on_attach callback here - --on_attach = function(client, bufnr) - -- if 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({ - -- bufnr = bufnr, - -- filter = function() - -- return client.name == "null-ls" - -- end, - -- }) - -- end, - -- }) - -- end - --end, -}) diff --git a/lua/mappings.lua b/lua/mappings.lua new file mode 100644 index 0000000..299ef21 --- /dev/null +++ b/lua/mappings.lua @@ -0,0 +1,59 @@ +local opts = { noremap = true, silent = true } + +--Local term_opts = { silent = true } +local keymap = vim.keymap.set + +-- Bind a leader key +keymap("", "", "", opts) -- release previously binded key +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Modes +-- Normal Mode = 'n', +-- Insert Mode = 'i', +-- Visual Mode = 'v', +-- Visual Block Mode = 'x', +-- Terminal Mode = 't', +-- Command Mode = 'c', + +-- Resize with arrow-keys +keymap("n", "", ":resize -2", opts) +keymap("n", "", ":resize +2", opts) +keymap("n", "", ":vertical resize -2", opts) +keymap("n", "", ":vertical resize +2", opts) + +-- Telescope fuzzy finder +local telescope_status_ok, telescope = pcall(require, "telescope.builtin") +if telescope_status_ok then + keymap("n", "ff", telescope.find_files, {}) + keymap("n", "ll", telescope.live_grep, {}) + keymap("n", "bb", telescope.buffers, {}) + keymap("n", "tt", telescope.treesitter, {}) +end + +-- Lsp controls +keymap("n", "ls", ":LspStart", opts) +keymap("n", "lS", ":LspStop", opts) +keymap("n", "lr", ":LspRestart", opts) +keymap("n", "li", ":LspInfo", opts) + +-- Buffer controls +keymap("n", "BB", ":bdelete", opts) +keymap("n", "jj", ":bprevious", opts) +keymap("n", "kk", ":bnext", opts) + +keymap("n", "P", '"+p', opts) +keymap("v", "Y", '"+y', opts) + +-- Toggleterm controls +function _G.set_terminal_keymaps() + local topts = { buffer = 0 } + keymap("t", "", [[]], topts) + keymap("t", "", [[wincmd h]], topts) + keymap("t", "", [[wincmd j]], topts) + keymap("t", "", [[wincmd k]], topts) + keymap("t", "", [[wincmd l]], topts) + keymap("t", "", [[]], topts) +end + +vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()") diff --git a/lua/plugins.lua b/lua/plugins.lua index 67a80e7..21e9ebc 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,78 +1,81 @@ -local ok, packer = pcall(require, "packer") -if not ok then - return +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) -packer.startup(function(use) - -- Visible indentation - use("lukas-reineke/indent-blankline.nvim") - - use("AlessandroYorba/Alduin") +local plugins = { + { "stevearc/dressing.nvim", event = "VeryLazy" }, + { "ellisonleao/gruvbox.nvim", priority = 1000, config = true }, + { "EdenEast/nightfox.nvim" }, + { "rebelot/kanagawa.nvim" }, + { "savq/melange-nvim" }, + { + "akinsho/bufferline.nvim", + version = "*", + dependencies = "nvim-tree/nvim-web-devicons", + config = true, + }, + { "lewis6991/gitsigns.nvim" }, + { "williamboman/mason.nvim" }, + { "williamboman/mason-lspconfig.nvim" }, + { "neovim/nvim-lspconfig" }, + { "jose-elias-alvarez/null-ls.nvim" }, + { "L3MON4D3/LuaSnip" }, + { "rafamadriz/friendly-snippets" }, + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "saadparwaiz1/cmp_luasnip" }, + { "onsails/lspkind.nvim" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "nvim-treesitter/nvim-treesitter" }, + { "simrat39/rust-tools.nvim" }, + { "nvim-lualine/lualine.nvim" }, + { "norcalli/nvim-colorizer.lua" }, + { "github/copilot.vim" }, + { + "nvim-telescope/telescope.nvim", + --tag = "0.1.2", + branch = "0.1.x", + dependencies = { "nvim-lua/plenary.nvim", { "nvim-telescope/telescope-fzf-native.nvim", build = "make" } }, + }, + --{ + -- "nvim-neo-tree/neo-tree.nvim", + -- branch = "v3.x", + -- dependencies = { + -- "nvim-lua/plenary.nvim", + -- "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + -- "MunifTanjim/nui.nvim", + -- -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + -- }, + --}, + { + { + "akinsho/toggleterm.nvim", + version = "*", + opts = { + open_mapping = [[]], + hide_numbers = true, + start_in_insert = true, + direction = "tab", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + }, + }, + }, + }, +} - -- Git integration - use("lewis6991/gitsigns.nvim") +local opts = {} - -- Transparency enabler - use("xiyaowong/transparent.nvim") - - -- Nord colorscheme - use("shaunsingh/nord.nvim") - - -- Dracula colorscheme - use("Mofiqul/dracula.nvim") - - -- Onedark colorscheme - use("navarasu/onedark.nvim") - - -- Gruvbox colorscheme - use("ellisonleao/gruvbox.nvim") - - --Everforest colorscheme - use("sainnhe/everforest") - - -- Catppuccin colorscheme - use({ "catppuccin/nvim", as = "catppuccin" }) - - -- Plugin manager - use("wbthomason/packer.nvim") - - -- Terminal - use({ "akinsho/toggleterm.nvim", tag = "*" }) - - -- File tree - use({ "nvim-tree/nvim-tree.lua", requires = { "nvim-tree/nvim-web-devicons" }, tag = "nightly" }) - - -- Statusline - use({ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons", opt = true } }) - - -- Buffer tabs - use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) - - use({ "nvim-telescope/telescope.nvim", tag = "0.1.x", requires = { { "nvim-lua/plenary.nvim" } } }) - - -- LSP manager - use("williamboman/mason.nvim") - use("williamboman/mason-lspconfig.nvim") - use("neovim/nvim-lspconfig") - - -- Formatting - use("jose-elias-alvarez/null-ls.nvim") - - -- Snippets - use("L3MON4D3/LuaSnip") --snippet engine - use("rafamadriz/friendly-snippets") -- a bunch of snippets to use - - -- Completions - use("hrsh7th/nvim-cmp") -- The completion plugin - use("hrsh7th/cmp-buffer") -- buffer completions - use("hrsh7th/cmp-path") -- path completions - use("saadparwaiz1/cmp_luasnip") -- snippet completions - use("onsails/lspkind.nvim") - use("hrsh7th/cmp-nvim-lsp") - - -- Syntax highlighting - use("nvim-treesitter/nvim-treesitter") - - -- Rust tools - use("simrat39/rust-tools.nvim") -end) +require("lazy").setup(plugins, opts) diff --git a/lua/setup/cmp.lua b/lua/setup/cmp.lua new file mode 100644 index 0000000..6fad8eb --- /dev/null +++ b/lua/setup/cmp.lua @@ -0,0 +1,126 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end + +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") +end + +local kind_icons = { + Text = "󰉿", + Method = "󰆧", + Function = "󰊕", + Constructor = "", + Field = " ", + Variable = "󰀫", + Class = "󰠱", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "󰑭", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈙", + Reference = "", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "", + Event = "", + Operator = "󰆕", + TypeParameter = " ", + Misc = " ", +} +-- find more here: https://www.nerdfonts.com/cheat-sheet + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- Accept currently selected item. If none selected, `select` first item. + -- Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + experimental = { + ghost_text = false, + native_menu = false, + }, +}) diff --git a/lua/setup/colorscheme.lua b/lua/setup/colorscheme.lua new file mode 100644 index 0000000..2b75da9 --- /dev/null +++ b/lua/setup/colorscheme.lua @@ -0,0 +1,7 @@ +local ok, nightfox = pcall(require, "nightfox") +if not ok then + return +end + +-- setup must be called before loading +vim.cmd("colorscheme carbonfox") diff --git a/lua/git-integration.lua b/lua/setup/gitsigns.lua similarity index 100% rename from lua/git-integration.lua rename to lua/setup/gitsigns.lua diff --git a/lua/setup/gui.lua b/lua/setup/gui.lua new file mode 100644 index 0000000..3111010 --- /dev/null +++ b/lua/setup/gui.lua @@ -0,0 +1,8 @@ +if vim.g.neovide then + vim.g.neovide_padding_top = 8 + vim.g.neovide_padding_bottom = 8 + vim.g.neovide_padding_right = 8 + vim.g.neovide_padding_left = 8 + vim.g.neovide_transparency = 1 + vim.o.guifont = "JetBrainsMonoNL Nerd Font:h10" +end diff --git a/lua/statusline.lua b/lua/setup/lualine.lua similarity index 100% rename from lua/statusline.lua rename to lua/setup/lualine.lua diff --git a/lua/setup/null-ls.lua b/lua/setup/null-ls.lua new file mode 100644 index 0000000..8870f17 --- /dev/null +++ b/lua/setup/null-ls.lua @@ -0,0 +1,35 @@ +local ok, null_ls = pcall(require, "null-ls") +if not ok then + return +end + +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +null_ls.setup({ + sources = { + null_ls.builtins.formatting.rustfmt, + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.prettier, + null_ls.builtins.formatting.clang_format, + }, + + -- you can reuse a shared lspconfig on_attach callback here + on_attach = function(client, bufnr) + if 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({ + bufnr = bufnr, + filter = function() + return client.name == "null-ls" + end, + }) + end, + }) + end + end, +}) diff --git a/lua/setup/nvim-cmp.lua b/lua/setup/nvim-cmp.lua new file mode 100644 index 0000000..bf69666 --- /dev/null +++ b/lua/setup/nvim-cmp.lua @@ -0,0 +1,93 @@ +local ok, cmp = pcall(require, "cmp") +if not ok then + return +end + +local luasnip_ok, luasnip = pcall(require, "luasnip") +if not luasnip_ok then + return +end + +local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode") +if not luasnip_vscode_ok then + return +end + +local lspkind_ok, lspkind = pcall(require, "lspkind") +if not lspkind_ok then + return +end + +luasnip_vscode.lazy_load() + +local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +cmp.setup({ + view = { + --entries = { name = "custom", selection_order = "near_cursor" }, + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + experimental = { + ghost_text = false, + }, + formatting = { + fields = { "abbr", "kind", "menu" }, + format = function(entry, vim_item) + local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. (strings[1] or "") .. " " + kind.menu = (strings[2] or "") + + return kind + end, + }, +}) diff --git a/lua/lsp-config.lua b/lua/setup/nvim-lspconfig.lua similarity index 100% rename from lua/lsp-config.lua rename to lua/setup/nvim-lspconfig.lua diff --git a/lua/fuzzy-finder.lua b/lua/setup/telescope.lua similarity index 65% rename from lua/fuzzy-finder.lua rename to lua/setup/telescope.lua index 0820942..cea8c22 100644 --- a/lua/fuzzy-finder.lua +++ b/lua/setup/telescope.lua @@ -3,16 +3,24 @@ if not status_ok then return end +local actions_ok, actions = pcall(require, "telescope.actions") +if not actions_ok then + return +end + telescope.setup({ defaults = { -- Default configuration for telescope goes here: -- config_key = value, mappings = { i = { - -- map actions.which_key to (default: ) - -- actions.which_key shows the mappings for your picker, + -- map telescope.actions.which_key to (default: ) + -- telescope.actions.which_key shows the mappings for your picker, -- e.g. git_{create, delete, ...}_branch for the git_branches picker [""] = "which_key", + [""] = actions.move_selection_previous, + [""] = actions.move_selection_next, + [""] = actions.send_selected_to_qflist + actions.open_qflist, }, }, }, @@ -36,3 +44,5 @@ telescope.setup({ -- please take a look at the readme of the extension you want to configure }, }) + +telescope.load_extension("fzf") diff --git a/lua/syntax-highlight.lua b/lua/setup/treesitter.lua similarity index 100% rename from lua/syntax-highlight.lua rename to lua/setup/treesitter.lua diff --git a/lua/terminal.lua b/lua/terminal.lua deleted file mode 100644 index 5fb7c49..0000000 --- a/lua/terminal.lua +++ /dev/null @@ -1,16 +0,0 @@ -local ok, toggleterm = pcall(require, "toggleterm") -if not ok then - return -end - -toggleterm.setup({ - open_mapping = [[]], - hide_numbers = true, - start_in_insert = true, - direction = "float", - close_on_exit = true, - shell = vim.o.shell, - float_opts = { - border = "curved", - }, -}) diff --git a/lua/transparency.lua b/lua/transparency.lua deleted file mode 100644 index 452c958..0000000 --- a/lua/transparency.lua +++ /dev/null @@ -1,33 +0,0 @@ -local ok, transparency = pcall(require, "transparency") -if not ok then - return -end - -transparency.setup({ - groups = { -- table: default groups - "Normal", - "NormalNC", - "Comment", - "Constant", - "Special", - "Identifier", - "Statement", - "PreProc", - "Type", - "Underlined", - "Todo", - "String", - "Function", - "Conditional", - "Repeat", - "Operator", - "Structure", - "LineNr", - "NonText", - "SignColumn", - "CursorLineNr", - "EndOfBuffer", - }, - extra_groups = {}, -- table: additional groups that should be cleared - exclude_groups = {}, -- table: groups you don't want to clear -}) diff --git a/lua/visible-indents.lua b/lua/visible-indents.lua deleted file mode 100644 index 4010259..0000000 --- a/lua/visible-indents.lua +++ /dev/null @@ -1,12 +0,0 @@ -local ok, indent_blankline = pcall(require, "indent_blankline") -if not ok then - return -end - -vim.cmd([[let g:indent_blankline_char = '¦']]) - -indent_blankline.setup({ - -- for example, context is off by default, use this to turn it on - show_current_context = true, - show_current_context_start = true, -})