diff --git a/.gitignore b/.gitignore index fe8e385..dbbbb7e 100644 --- a/.gitignore +++ b/.gitignore @@ -149,4 +149,4 @@ fabric.properties # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser -nvim/plugin/ +lazy-lock.json diff --git a/README.md b/README.md index 4ca1afe..991e938 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,14 @@ Table of contents - [1. Introduction](#1-introduction) - [2. Installation](#2-installation) -- [3. Plugins \& LSP](#3-plugins--lsp) - - [3.1. Plugins](#31-plugins) - - [3.2. LSP](#32-lsp) -- [4. Keymaps](#4-keymaps) -- [5. Screenshots](#5-screenshots) -- [6. Contribution](#6-contribution) -- [7. Guide and resources](#7-guide-and-resources) +- [3. File structure](#3-file-structure) +- [4. Plugins \& LSP](#4-plugins--lsp) + - [4.1. Plugins](#41-plugins) + - [4.2. LSP](#42-lsp) +- [5. Keymaps](#5-keymaps) +- [6. Screenshots](#6-screenshots) +- [7. Contribution](#7-contribution) +- [8. Guide and resources](#8-guide-and-resources) ## 1. Introduction @@ -48,7 +49,9 @@ Therefore, I decided to create this repository. There are several versions: - [v0.1.0](https://github.com/ntk148v/neovim-config/tree/v0.1.0): written in VimL, a single file only. - [v0.1.1](https://github.com/ntk148v/neovim-config/tree/v0.1.1): written in VimL, consist of mutliple files. -- [v0.2.0](https://github.com/ntk148v/neovim-config/tree/v0.2.0): started this version, switch from VimL to Lua. For the reason, you may to check [neovim's official wiki](https://github.com/neovim/neovim/wiki/FAQ#why-embed-lua-instead-of-x). Follow [KISS principle](https://en.wikipedia.org/wiki/KISS_principle), this version uses the least plugins as possible. It's more like a skeleton, users can add more plugins and LSP. +- [v0.2.0](https://github.com/ntk148v/neovim-config/tree/v0.2.0): started from this version, switch from VimL to Lua. For the reason, you may to check [neovim's official wiki](https://github.com/neovim/neovim/wiki/FAQ#why-embed-lua-instead-of-x). Follow [KISS principle](https://en.wikipedia.org/wiki/KISS_principle), this version uses the least plugins as possible. It's more like a skeleton, users can add more plugins and LSP. +- [v0.2.1](https://github.com/ntk148v/neovim-config/tree/v0.2.1): this version contains some minor changes. +- [v0.3.0](https://github.com/ntk148v/neovim-config/tree/v0.3.0): I decide to switch to [lazy.nvim](https://github.com/folke/lazy.nvim) as my plugin manager, instead of [packer](https://github.com/wbthomason/packer.nvim). The main reason is [lazy.nvim's support for plugin structure](https://github.com/folke/lazy.nvim#-structuring-your-plugins). As I mentioned, this config is meant as a starting point, it is not a complete Neovim/Vim config distribution, if you're looking for a one, check out [here](https://github.com/rockerBOO/awesome-neovim#preconfigured-configuration). @@ -56,8 +59,8 @@ As I mentioned, this config is meant as a starting point, it is not a complete N - Requirements: - Install [neovim >= 0.8.0](https://github.com/neovim/neovim/wiki/Installing-Neovim#install-from-package), or you can [build it](https://github.com/neovim/neovim/wiki/Building-Neovim#) yourself. - - git -- I recommend using a [nerdfonts](https://www.nerdfonts.com/font-downloads) + - git >= 2.19.0 (for partial clones suppot) + - I recommend using a [nerdfonts](https://www.nerdfonts.com/font-downloads) (optional) - Backup your current neovim config, if necessary: ```shell @@ -72,19 +75,44 @@ cd neovim-config.git/ cp -Rv nvim ~/.config/ ``` -- Start Neovim, Packer should be installed automatically, then run the following command to install plugins: +- Start Neovim, Lazy should be installed automatically, then it will install plugins. -```vim -:PackerSync +## 3. File structure + +The files under config will be automatically loaded at the appropriate time, so you don't need to require those files manually. + +```shell +tree ~/.config/nvim +├── init.lua +├── lazy-lock.json +└── lua + ├── config + │   ├── autocmds.lua + │   ├── init.lua + │   ├── keymaps.lua + │   └── options.lua + └── plugins + ├── autopairs.lua + ├── colorizer.lua + ├── colorscheme.lua + ├── comment.lua + ├── gitsigns.lua + ├── lsp.lua + ├── lualine.lua + ├── neoterm.lua + ├── null-ls.lua + ├── telescope.lua + ├── tree.lua + └── treesitter.lua ``` -## 3. Plugins & LSP +## 4. Plugins & LSP -### 3.1. Plugins +### 4.1. Plugins | Plugin | Description | | --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [packer.nvim](https://github.com/wbthomason/packer.nvim) | A use-package inspired plugin manager for Neovim | +| [lazy.nvim](https://github.com/folke/lazy.nvim) | A modern plugin manager for Neovim | | [mason.nvim](https://github.com/williamboman/mason.nvim) | Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters. | | [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) | A collection of common configurations for Neovim's built-in language server client | | [gitsigns](https://github.com/lewis6991/gitsigns.nvim) | Super fast git decorations implemented purely in lua/teal | @@ -102,9 +130,11 @@ cp -Rv nvim ~/.config/ | [rosé-pine](https://github.com/rose-pine/neovim) | Soho vibes for Neovim | | [folke/tokyonight.nvim](https://github.com/folke/tokyonight.nvim) | A clean, dark Neovim theme written in Lua, with support for lsp, treesitter and lots of plugins. Includes additional themes for Kitty, Alacritty, iTerm and Fish. | | [projekt0n/github-nvim-theme](https://github.com/projekt0n/github-nvim-theme) | Github's Neovim themes | -| [null-ls](https://github.com/jose-elias-alvarez/null-ls.nvim) | Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua. | +| [null-ls](https://github.com/jose-elias-alvarez/null-ls.nvim) | Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua. | + +**You can add your custom plugin specs under `lua/plugins`. All files will be automatically loaded by `lazy.nvim`.** -### 3.2. LSP +### 4.2. LSP This configuration provides Python and Golang dev environment. The programming language server is current supported: @@ -133,7 +163,7 @@ If your language is not supported, please follow this: :TSInstall `` ``` -## 4. Keymaps +## 5. Keymaps These are the default keymaps, in the following shortcuts, the `` key is set up to `` (space) character, check: [keymaps.lua](./nvim/lua/core/keymaps.lua). @@ -166,19 +196,19 @@ There are many default keymaps, you can check it using `:map` command. There are The above list is not complete. Typing `:help map` in Vim will give you more info. -## 5. Screenshots +## 6. Screenshots | | | | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | | dark | dark | | dark | dark | -| dark | | +| dark | dark | -## 6. Contribution +## 7. Contribution Feel free to file an issue or open a pull request. You're welcome! -## 7. Guide and resources +## 8. Guide and resources - [nanotee/nvim-lua-guide](https://github.com/nanotee/nvim-lua-guide) - [brainfucksec/neovim-lua](https://github.com/brainfucksec/neovim-lua) diff --git a/nvim/init.lua b/nvim/init.lua index d39ff68..b731a77 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,24 +1,24 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: init.lua --- Description: main configuration file --- Author: Kien Nguyen-Tuan if vim.fn.has('nvim-0.8') == 0 then error('Need Neovim 0.8+ in order to use this config') end --- Import Lua modules -- -local modules = {'loader', 'plugins', 'core'} +for _, cmd in ipairs({"git", "rg", {"fd", "fdfind"}}) do + local name = type(cmd) == "string" and cmd or vim.inspect(cmd) + local commands = type(cmd) == "string" and {cmd} or cmd + ---@cast commands string[] + local found = false -for _, mod in ipairs(modules) do - local ok, err = pcall(require, mod) - if not ok then - error(('Error loading %s...\n\n%s'):format(mod, err)) + for _, c in ipairs(commands) do + if vim.fn.executable(c) == 1 then + name = c + found = true + end + end + + if not found then + error(("`%s` is not installed"):format(name)) end end + +-- Load main config +require("config") diff --git a/nvim/lua/core/autocmd.lua b/nvim/lua/config/autocmds.lua similarity index 71% rename from nvim/lua/core/autocmd.lua rename to nvim/lua/config/autocmds.lua index a0778c3..6d56c65 100644 --- a/nvim/lua/core/autocmd.lua +++ b/nvim/lua/config/autocmds.lua @@ -6,7 +6,7 @@ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- --- File: core/autocmds.lua +-- File: config/autocmds.lua -- Description: Autocommand functions -- Author: Kien Nguyen-Tuan -- Define autocommands with Lua APIs @@ -17,46 +17,46 @@ local autocmd = vim.api.nvim_create_autocmd -- Create autocommand -- General settings -- Highlight on yank -autocmd('TextYankPost', { +autocmd("TextYankPost", { callback = function() vim.highlight.on_yank({ - higroup = 'IncSearch', - timeout = '1000' + higroup = "IncSearch", + timeout = "1000" }) end }) -- Remove whitespace on save -autocmd('BufWritePre', { - pattern = '', +autocmd("BufWritePre", { + pattern = "", command = ":%s/\\s\\+$//e" }) -- Auto format on save using the attached (optionally filtered) language servere clients -- https://neovim.io/doc/user/lsp.html#vim.lsp.buf.format() -autocmd('BufWritePre', { - pattern = '', - command = ':silent lua vim.lsp.buf.format()' +autocmd("BufWritePre", { + pattern = "", + command = ":silent lua vim.lsp.buf.format()" }) --- Don't auto commenting new lines -autocmd('BufEnter', { - pattern = '', - command = 'set fo-=c fo-=r fo-=o' +-- Don"t auto commenting new lines +autocmd("BufEnter", { + pattern = "", + command = "set fo-=c fo-=r fo-=o" }) -autocmd('Filetype', { - pattern = {'xml', 'html', 'xhtml', 'css', 'scss', 'javascript', 'typescript', 'yaml', 'lua'}, - command = 'setlocal shiftwidth=2 tabstop=2' +autocmd("Filetype", { + pattern = {"xml", "html", "xhtml", "css", "scss", "javascript", "typescript", "yaml", "lua"}, + command = "setlocal shiftwidth=2 tabstop=2" }) -- Set colorcolumn -autocmd('Filetype', { - pattern = {'python', 'rst', 'c', 'cpp'}, - command = 'set colorcolumn=80' +autocmd("Filetype", { + pattern = {"python", "rst", "c", "cpp"}, + command = "set colorcolumn=80" }) -autocmd('Filetype', { +autocmd("Filetype", { pattern = {"gitcommit", "markdown", "text"}, callback = function() vim.opt_local.wrap = true diff --git a/nvim/lua/config/init.lua b/nvim/lua/config/init.lua new file mode 100644 index 0000000..c04091d --- /dev/null +++ b/nvim/lua/config/init.lua @@ -0,0 +1,51 @@ +-- +-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ +-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ +-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ +-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ +-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ +-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +-- +-- File: config/init.lua +-- Description: Main configurations +-- Author: Kien Nguyen-Tuan +-- Lazy.nvim +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) + +local modules = {"config.autocmds", "config.options", "config.keymaps"} + +for _, mod in ipairs(modules) do + local ok, err = pcall(require, mod) + if not ok then + error(("Error loading %s...\n\n%s"):format(mod, err)) + end +end + +require("lazy").setup({ + root = vim.fn.stdpath("data") .. "/lazy", -- directory where plugins will be installed + spec = {{ + import = "plugins" + }}, + lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update. + defaults = { + lazy = false, -- should plugins be lazy-loaded? + version = nil + -- version = "*", -- enable this to try installing the latest stable versions of plugins + }, + install = { + -- install missing plugins on startup + missing = true, + -- try to load one of these colorschemes when starting an installation during startup + colorscheme = {"rose-pine", "blue"} + }, + checker = { + -- automatically check for plugin updates + enabled = true + } +}) diff --git a/nvim/lua/core/keymaps.lua b/nvim/lua/config/keymaps.lua similarity index 54% rename from nvim/lua/core/keymaps.lua rename to nvim/lua/config/keymaps.lua index b29e058..8b1e971 100644 --- a/nvim/lua/core/keymaps.lua +++ b/nvim/lua/config/keymaps.lua @@ -6,36 +6,36 @@ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- --- File: core/keymaps.lua +-- File: config/keymaps.lua -- Description: Key mapping configs -- Author: Kien Nguyen-Tuan -vim.g.mapleader = ' ' +vim.g.mapleader = " " -- Close all windows and exit from Neovim with and q -vim.keymap.set('n', 'q', ':qa!', {}) +vim.keymap.set("n", "q", ":qa!", {}) -- Fast saving with and s -vim.keymap.set('n', 's', ':w', {}) +vim.keymap.set("n", "s", ":w", {}) -- Move around splits -vim.keymap.set('n', 'wh', 'h', {}) -vim.keymap.set('n', 'wj', 'j', {}) -vim.keymap.set('n', 'wk', 'k', {}) -vim.keymap.set('n', 'wl', 'l', {}) +vim.keymap.set("n", "wh", "h", {}) +vim.keymap.set("n", "wj", "j", {}) +vim.keymap.set("n", "wk", "k", {}) +vim.keymap.set("n", "wl", "l", {}) -- Reload configuration without restart nvim -vim.keymap.set('n', 'r', ':so %', {}) +vim.keymap.set("n", "r", ":so %", {}) -- Telescope -- is a space now -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fg', builtin.live_grep, {}) -vim.keymap.set('n', 'fb', builtin.buffers, {}) -vim.keymap.set('n', 'fh', builtin.help_tags, {}) +local builtin = require("telescope.builtin") +vim.keymap.set("n", "ff", builtin.find_files, {}) +vim.keymap.set("n", "fg", builtin.live_grep, {}) +vim.keymap.set("n", "fb", builtin.buffers, {}) +vim.keymap.set("n", "fh", builtin.help_tags, {}) -- NvimTree -vim.keymap.set('n', 'n', ':NvimTreeToggle', {}) -- open/close -vim.keymap.set('n', 'nr', ':NvimTreeRefresh', {}) -- refresh -vim.keymap.set('n', 'nf', ':NvimTreeFindFile', {}) -- search file +vim.keymap.set("n", "n", ":NvimTreeToggle", {}) -- open/close +vim.keymap.set("n", "nr", ":NvimTreeRefresh", {}) -- refresh +vim.keymap.set("n", "nf", ":NvimTreeFindFile", {}) -- search file -- Terminal -vim.keymap.set('n', 'tt', ':NeotermToggle', {}) --- vim.keymap.set('n', 'tx', ':NeotermExit', {}) +vim.keymap.set("n", "tt", ":NeotermToggle", {}) +-- vim.keymap.set("n", "tx", ":NeotermExit", {}) diff --git a/nvim/lua/core/options.lua b/nvim/lua/config/options.lua similarity index 82% rename from nvim/lua/core/options.lua rename to nvim/lua/config/options.lua index 8fcf62e..b417c1f 100644 --- a/nvim/lua/core/options.lua +++ b/nvim/lua/config/options.lua @@ -6,7 +6,7 @@ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- --- File: core/options.lua +-- File: config/options.lua -- Description: General Neovim settings and configuration -- Author: Kien Nguyen-Tuan local cmd = vim.cmd @@ -21,12 +21,12 @@ cmd([[ filetype plugin indent on ]]) -opt.backspace = {'eol', 'start', 'indent'} -- allow backspacing over everything in insert mode -opt.clipboard = 'unnamedplus' -- allow neovim to access the system clipboard +opt.backspace = {"eol", "start", "indent"} -- allow backspacing over everything in insert mode +opt.clipboard = "unnamedplus" -- allow neovim to access the system clipboard vim.opt.fileencoding = "utf-8" -- the encoding written to a file -opt.encoding = 'utf-8' -- the encoding -opt.matchpairs = {'(:)', '{:}', '[:]', '<:>'} -opt.syntax = 'enable' +opt.encoding = "utf-8" -- the encoding +opt.matchpairs = {"(:)", "{:}", "[:]", "<:>"} +opt.syntax = "enable" -- indention opt.autoindent = true -- auto indentation @@ -35,37 +35,37 @@ opt.shiftwidth = indent -- the number of spaces inserted for each indentation opt.smartindent = true -- make indenting smarter opt.softtabstop = indent -- when hitting , pretend like a tab is removed, even if spaces opt.tabstop = indent -- insert 2 spaces for a tab -opt.shiftround = true -- use multiple of shiftwidth when indenting with '<' and '>' +opt.shiftround = true -- use multiple of shiftwidth when indenting with "<" and ">" -- search opt.hlsearch = true -- highlight all matches on previous search pattern opt.ignorecase = true -- ignore case in search patterns opt.smartcase = true -- smart case -opt.wildignore = opt.wildignore + {'*/node_modules/*', '*/.git/*', '*/vendor/*'} +opt.wildignore = opt.wildignore + {"*/node_modules/*", "*/.git/*", "*/vendor/*"} opt.wildmenu = true -- make tab completion for files/buffers act like bash -- ui opt.cursorline = true -- highlight the current line opt.laststatus = 2 -- only the last window will always have a status line -opt.lazyredraw = true -- don't update the display while executing macros +opt.lazyredraw = true -- don"t update the display while executing macros opt.list = true --- You can also add 'space' or 'eol', but I feel it's quite annoying +-- You can also add "space" or "eol", but I feel it"s quite annoying opt.listchars = { - tab = '┊ ', - trail = '·', - extends = '»', - precedes = '«', - nbsp = '×' + tab = "┊ ", + trail = "·", + extends = "»", + precedes = "«", + nbsp = "×" } -- Hide cmd line opt.cmdheight = 0 -- more space in the neovim command line for displaying messages -opt.mouse = 'a' -- allow the mouse to be used in neovim +opt.mouse = "a" -- allow the mouse to be used in neovim opt.number = true -- set numbered lines opt.scrolloff = 18 -- minimal number of screen lines to keep above and below the cursor opt.sidescrolloff = 3 -- minimal number of screen columns to keep to the left and right (horizontal) of the cursor if wrap is `false` -opt.signcolumn = 'yes' -- always show the sign column, otherwise it would shift the text each time +opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time opt.splitbelow = true -- open new split below opt.splitright = true -- open new split to the right opt.wrap = false -- display a long line @@ -76,7 +76,7 @@ opt.swapfile = false -- creates a swapfile opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited -- autocomplete -opt.completeopt = {'menu', 'menuone', 'noselect'} -- mostly just for cmp +opt.completeopt = {"menu", "menuone", "noselect"} -- mostly just for cmp opt.shortmess = opt.shortmess + { c = true } -- hide all the completion messages, e.g. "-- XXX completion (YYY)", "match 1 of 2", "The only match", "Pattern not found" @@ -96,15 +96,15 @@ opt.updatetime = 100 -- signify default updatetime 4000ms is not good for async opt.termguicolors = true -- enable 24-bit RGB colors -- persistent undo --- Don't forget to create folder $HOME/.local/share/nvim/undo -local undodir = vim.fn.stdpath('data') .. '/undo' +-- Don"t forget to create folder $HOME/.local/share/nvim/undo +local undodir = vim.fn.stdpath("data") .. "/undo" opt.undofile = true -- enable persistent undo opt.undodir = undodir opt.undolevels = 1000 opt.undoreload = 10000 -- fold -opt.foldmethod = 'marker' +opt.foldmethod = "marker" opt.foldlevel = 99 -- Disable builtin plugins @@ -119,4 +119,4 @@ end -- Colorscheme -- By default, use rose-pine -cmd('colorscheme rose-pine') +cmd.colorscheme("rose-pine") diff --git a/nvim/lua/core/init.lua b/nvim/lua/core/init.lua deleted file mode 100644 index 0ccc911..0000000 --- a/nvim/lua/core/init.lua +++ /dev/null @@ -1,20 +0,0 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: core/init.lua --- Description: Main configurations --- Author: Kien Nguyen-Tuan --- Import Lua modules -- -local modules = {'core.autocmd', 'core.options', 'core.keymaps'} - -for _, mod in ipairs(modules) do - local ok, err = pcall(require, mod) - if not ok then - error(('Error loading %s...\n\n%s'):format(mod, err)) - end -end diff --git a/nvim/lua/loader.lua b/nvim/lua/loader.lua deleted file mode 100644 index e0670fd..0000000 --- a/nvim/lua/loader.lua +++ /dev/null @@ -1,149 +0,0 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: plugins/loader.lua --- Description: Plugin manager configuration file --- Author: Kien Nguyen-Tuan --- Automatically install packer -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 - packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', - install_path}) - vim.o.runtimepath = vim.fn.stdpath('data') .. '/site/pack/*/start/*,' .. vim.o.runtimepath -end - --- Autocommand that reloads neovim whenever you save file -vim.cmd [[ - augroup packer_user_config - autocmd! - autocmd BufWritePost loader.lua source | PackerSync - augroup end -]] - --- Use a protected call so we don't error out on first use -local status_ok, packer = pcall(require, 'packer') -if not status_ok then - return -end - --- Install plugins -return packer.startup({ - function(use) - use 'wbthomason/packer.nvim' -- packer can manage itself - - -- Treesitter interface - use { - 'nvim-treesitter/nvim-treesitter', - run = function() - require('nvim-treesitter.install').update({ - with_sync = true - }) - end - } - - -- LSP - Quickstart configs for Nvim LSP - use {'neovim/nvim-lspconfig'} - -- Mason - -- Portable package manager for Neovim that runs everywhere Neovim runs. - -- Easily install and manage LSP servers, DAP servers, linters, and formatters. - use {'williamboman/mason.nvim'} - use {'williamboman/mason-lspconfig.nvim'} - - -- Color schemes - -- Rose-pine - Soho vibes for Neovim - use { - 'rose-pine/neovim', - as = 'rose-pine' - } - -- Tokyonight - A clean, dark Neovim theme written in Lua, with support for lsp, - -- treesitter and lots of plugins. Includes additional themes for Kitty, Alacritty, iTerm and Fish. - use 'folke/tokyonight.nvim' - -- Github - Github's Neovim themes - use 'projekt0n/github-nvim-theme' - - -- Statusline - -- A blazing fast and easy to configure neovim statusline plugin written in pure lua. - use 'nvim-lualine/lualine.nvim' - - -- File explore - -- nvim-tree.lua - A file explorer tree for neovim written in lua - use { - 'nvim-tree/nvim-tree.lua', - requires = { - 'nvim-tree/nvim-web-devicons', - opt = true - } - } - - -- Autopairs - use { - 'windwp/nvim-autopairs', - config = function() - require('nvim-autopairs').setup {} - end - } - - -- Autocomplete - -- A completion plugin for neovim coded in Lua. - use { - 'hrsh7th/nvim-cmp', - requires = {'L3MON4D3/LuaSnip', 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-path', 'hrsh7th/cmp-buffer', - 'saadparwaiz1/cmp_luasnip'} - } - - -- Use Neovim as a language server to inject LSP diagnostics, - -- code actions, and more via Lua. - use 'jose-elias-alvarez/null-ls.nvim' - - -- Smart and powerful comment plugin for neovim. - -- Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more - use 'numToStr/Comment.nvim' - - -- Git integration for buffers - use 'lewis6991/gitsigns.nvim' - - -- Colorizer - use 'norcalli/nvim-colorizer.lua' - - -- Telescope - -- Find, Filter, Preview, Pick. All lua, all the time. - use { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - requires = {'nvim-lua/plenary.nvim'} - } - use { - 'nvim-telescope/telescope-fzf-native.nvim', - run = 'make', - requires = {'nvim-telescope/telescope.nvim'} - } - - -- Floating terminal - use 'itmecho/neoterm.nvim' - - -- Automatically set up your configuration after cloning packer.nvim - -- Put this at the end after all plugins - if packer_bootstrap then - require('packer').sync() - end - end, - config = { - display = { - open_fn = function() - return require('packer.util').float({ - border = 'single' - }) - end - }, - profile = { - enable = false - } - } -}) diff --git a/nvim/lua/plugins/autopairs.lua b/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..3023d01 --- /dev/null +++ b/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,42 @@ +-- +-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ +-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ +-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ +-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ +-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ +-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +-- +-- File: plugins/autopairs.lua +-- Description: nvim-autopairs config +-- Author: Kien Nguyen-Tuan +return { -- Autopairs +{ + "windwp/nvim-autopairs", + opts = { + check_ts = true, + ts_config = { + lua = {"string"}, -- it will not add a pair on that treesitter node + javascript = {"template_string"}, + java = false -- don"t check treesitter on java + }, + + -- Don"t add pairs if it already has a close pair in the same line + enable_check_bracket_line = false, + + -- Don"t add pairs if the next char is alphanumeric + ignored_next_char = "[%w%.]", -- will ignore alphanumeric and `.` symbol + fast_wrap = {}, + disable_filetype = {"TelescopePrompt", "vim"} + }, + config = function(_, opts) + local npairs = require("nvim-autopairs") + npairs.setup(opts) + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ + map_char = { + tex = "" + } + })) + end +}} diff --git a/nvim/lua/plugins/nvim-colorizer.lua b/nvim/lua/plugins/colorizer.lua similarity index 90% rename from nvim/lua/plugins/nvim-colorizer.lua rename to nvim/lua/plugins/colorizer.lua index 5b17459..613c3d4 100644 --- a/nvim/lua/plugins/nvim-colorizer.lua +++ b/nvim/lua/plugins/colorizer.lua @@ -6,8 +6,8 @@ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- --- File: plugins/nvim-colorizer.lua +-- File: plugins/colorizer.lua -- Description: nvim-colorizer config -- Author: Kien Nguyen-Tuan --- Attaches to every FileType mode -require('colorizer').setup() +return { -- colorizer +{"norcalli/nvim-colorizer.lua"}} diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua index e29dc5c..f3cc088 100644 --- a/nvim/lua/plugins/colorscheme.lua +++ b/nvim/lua/plugins/colorscheme.lua @@ -9,77 +9,52 @@ -- File: plugins/colorscheme.lua -- Description: Colorscheme config -- Author: Kien Nguyen-Tuan -require("github-theme").setup({ - theme_style = "dark", - function_style = "italic", - sidebars = {"qf", "vista_kind", "terminal", "packer"}, +return { -- Rose-pine - Soho vibes for Neovim +{ + "rose-pine/neovim", + name = "rose-pine", + lazy = false, + opts = { + dark_variant = "main" + } +}, -- Github - Github"s Neovim themes +{ + "projekt0n/github-nvim-theme", + lazy = true, + opts = { + theme_style = "dark", + function_style = "italic", + sidebars = {"qf", "vista_kind", "terminal", "packer"}, - -- Change the "hint" color to the "orange" color, and make the "error" color bright red - colors = { - hint = "orange", - error = "#ff0000" - }, - - -- Overwrite the highlight groups - overrides = function(c) - return { - htmlTag = { - fg = c.red, - bg = "#282c34", - sp = c.hint, - style = "underline" - }, - DiagnosticHint = { - link = "LspDiagnosticsDefaultHint" - }, - -- this will remove the highlight groups - TSField = {} - } - end -}) - -require("tokyonight").setup({ - -- your configuration comes here - -- or leave it empty to use the default settings - style = "night", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day` - light_style = "day", -- The theme is used when the background is set to light - transparent = false, -- Enable this to disable setting the background color - terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim - styles = { - -- Style to be applied to different syntax groups - -- Value is any valid attr-list value for `:help nvim_set_hl` - comments = { - italic = true - }, - keywords = { - italic = true + -- Change the "hint" color to the "orange" color, and make the "error" color bright red + colors = { + hint = "orange", + error = "#ff0000" }, - functions = {}, - variables = {}, - -- Background styles. Can be "dark", "transparent" or "normal" - sidebars = "dark", -- style for sidebars, see below - floats = "dark" -- style for floating windows - }, - sidebars = {"qf", "help"}, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` - day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors - hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. - dim_inactive = false, -- dims inactive windows - lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold - - --- You can override specific color groups to use other groups or a hex color - --- function will be called with a ColorScheme table - ---@param colors ColorScheme - on_colors = function(colors) - end, - --- You can override specific highlights to use other groups or a hex color - --- function will be called with a Highlights and ColorScheme table - ---@param highlights Highlights - ---@param colors ColorScheme - on_highlights = function(highlights, colors) + -- Overwrite the highlight groups + overrides = function(c) + return { + htmlTag = { + fg = c.red, + bg = "#282c34", + sp = c.hint, + style = "underline" + }, + DiagnosticHint = { + link = "LspDiagnosticsDefaultHint" + }, + -- this will remove the highlight groups + TSField = {} + } + end + }, + config = function(_, opts) + require("github-theme").setup(opts) end -}) - -require('rose-pine').setup({ - dark_variant = 'main' -}) +}, -- Tokyonight- A clean, dark Neovim theme written in Lua, with support for lsp, +-- treesitter and lots of plugins. Includes additional themes for Kitty, Alacritty, iTerm and Fish. +{ + "folke/tokyonight.nvim", + lazy = true +}} diff --git a/nvim/lua/plugins/comment.lua b/nvim/lua/plugins/comment.lua index 877d16a..208b1a3 100644 --- a/nvim/lua/plugins/comment.lua +++ b/nvim/lua/plugins/comment.lua @@ -9,69 +9,78 @@ -- File: plugins/comment.lua -- Description: nvim comment config -- Author: Kien Nguyen-Tuan -require('Comment').setup { - active = true, - on_config_done = nil, - -- Add a space b/w comment and the line - -- @type boolean - padding = true, +return {{ + -- Smart and powerful comment plugin for neovim. + -- Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more + "numToStr/Comment.nvim", + opts = { + active = true, + on_config_done = nil, + -- Add a space b/w comment and the line + -- @type boolean + padding = true, - -- Whether cursor should stay at the - -- same position. Only works in NORMAL - -- mode mappings - sticky = true, + -- Whether cursor should stay at the + -- same position. Only works in NORMAL + -- mode mappings + sticky = true, - -- Lines to be ignored while comment/uncomment. - -- Could be a regex string or a function that returns a regex string. - -- Example: Use '^$' to ignore empty lines - -- @type string|function - ignore = "^$", + -- Lines to be ignored while comment/uncomment. + -- Could be a regex string or a function that returns a regex string. + -- Example: Use "^$" to ignore empty lines + -- @type string|function + ignore = "^$", - -- Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode - -- @type table - mappings = { - -- operator-pending mapping - -- Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}` - basic = true, - -- Extra mapping - -- Includes `gco`, `gcO`, `gcA` - extra = true - }, + -- Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode + -- @type table + mappings = { + -- operator-pending mapping + -- Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}` + basic = true, + -- Extra mapping + -- Includes `gco`, `gcO`, `gcA` + extra = true + }, - -- LHS of line and block comment toggle mapping in NORMAL/VISUAL mode - -- @type table - toggler = { - -- line-comment toggle - line = "mm", - -- block-comment toggle - block = "mbm" - }, + -- LHS of line and block comment toggle mapping in NORMAL/VISUAL mode + -- @type table + toggler = { + -- line-comment toggle + line = "mm", + -- block-comment toggle + block = "mbm" + }, - -- LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode - -- @type table - opleader = { - -- line-comment opfunc mapping - line = "m", - -- block-comment opfunc mapping - block = "mb" - }, + -- LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode + -- @type table + opleader = { + -- line-comment opfunc mapping + line = "m", + -- block-comment opfunc mapping + block = "mb" + }, - -- LHS of extra mappings - -- @type table - extra = { - -- Add comment on the line above - above = "mO", - -- Add comment on the line below - below = "mo", - -- Add comment at the end of line - eol = "mA" - }, + -- LHS of extra mappings + -- @type table + extra = { + -- Add comment on the line above + above = "mO", + -- Add comment on the line below + below = "mo", + -- Add comment at the end of line + eol = "mA" + }, - -- Pre-hook, called before commenting the line - -- @type function|nil - pre_hook = pre_hook, + -- Pre-hook, called before commenting the line + -- @type function|nil + pre_hook = pre_hook, - -- Post-hook, called after commenting is done - -- @type function|nil - post_hook = nil -} + -- Post-hook, called after commenting is done + -- @type function|nil + post_hook = nil + }, + ---@param opts TSConfig + config = function(_, opts) + require("Comment").setup() + end +}} diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua index af82a72..c7dbc23 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/gitsigns.lua @@ -9,82 +9,85 @@ -- File: plugins/gitsigns.lua -- Description: Gitsigns configuration -- Author: Kien Nguyen-Tuan -local status_ok, gitsigns = pcall(require, "gitsigns") -if not status_ok then - return -end - -gitsigns.setup { - signs = { - add = { - hl = 'GitSignsAdd', - text = '│', - numhl = 'GitSignsAddNr', - linehl = 'GitSignsAddLn' +return {{ + -- Git integration for buffers + "lewis6991/gitsigns.nvim", + opts = { + signs = { + add = { + hl = "GitSignsAdd", + text = "│", + numhl = "GitSignsAddNr", + linehl = "GitSignsAddLn" + }, + change = { + hl = "GitSignsChange", + text = "│", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn" + }, + delete = { + hl = "GitSignsDelete", + text = "_", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn" + }, + topdelete = { + hl = "GitSignsDelete", + text = "‾", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn" + }, + changedelete = { + hl = "GitSignsChange", + text = "~", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn" + }, + untracked = { + hl = "GitSignsAdd", + text = "┆", + numhl = "GitSignsAddNr", + linehl = "GitSignsAddLn" + } }, - change = { - hl = 'GitSignsChange', - text = '│', - numhl = 'GitSignsChangeNr', - linehl = 'GitSignsChangeLn' + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true }, - delete = { - hl = 'GitSignsDelete', - text = '_', - numhl = 'GitSignsDeleteNr', - linehl = 'GitSignsDeleteLn' + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- "eol" | "overlay" | "right_align" + delay = 1000, + ignore_whitespace = false }, - topdelete = { - hl = 'GitSignsDelete', - text = '‾', - numhl = 'GitSignsDeleteNr', - linehl = 'GitSignsDeleteLn' + current_line_blame_formatter_opts = { + relative_time = false }, - changedelete = { - hl = 'GitSignsChange', - text = '~', - numhl = 'GitSignsChangeNr', - linehl = 'GitSignsChangeLn' + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1 }, - untracked = { - hl = 'GitSignsAdd', - text = '┆', - numhl = 'GitSignsAddNr', - linehl = 'GitSignsAddLn' + yadm = { + enable = false } }, - signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` - numhl = false, -- Toggle with `:Gitsigns toggle_numhl` - linehl = false, -- Toggle with `:Gitsigns toggle_linehl` - word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` - watch_gitdir = { - interval = 1000, - follow_files = true - }, - attach_to_untracked = true, - current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' - delay = 1000, - ignore_whitespace = false - }, - current_line_blame_formatter_opts = { - relative_time = false - }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - max_file_length = 40000, - preview_config = { - -- Options passed to nvim_open_win - border = "single", - style = "minimal", - relative = "cursor", - row = 0, - col = 1 - }, - yadm = { - enable = false - } -} + ---@param opts TSConfig + config = function(_, opts) + require("gitsigns").setup(opts) + end +}} diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua deleted file mode 100644 index 196e405..0000000 --- a/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,23 +0,0 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: plugins.init.lua --- Description: Custom plugins configuration --- Author: Kien Nguyen-Tuan --- Custom plugin configs -local modules = {'plugins.statusline', 'plugins.nvim-tree', 'plugins.nvim-treesitter', 'plugins.comment', - 'plugins.nvim-telescope', 'plugins.nvim-autopairs', 'plugins.colorscheme', 'plugins.lsp', - 'plugins.null-ls', 'plugins.nvim-colorizer', 'plugins.term', 'plugins.gitsigns'} - -for _, mod in ipairs(modules) do - local ok, err = pcall(require, mod) - if not ok then - error(('Error loading %s...\n\n%s'):format(mod, err)) - end -end - diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index d095b49..4b61372 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -10,91 +10,189 @@ -- Description: LSP setup and config -- Author: Kien Nguyen-Tuan -- Enable some language servers with the additional completion capabilities offered by nvim-cmp -local servers = {'dockerls', 'bashls', 'gopls', 'pyright', 'jsonls', 'vimls', 'yamlls'} -require("mason").setup() -require("mason-lspconfig").setup({ - -- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer@nightly", "sumneko_lua" } - -- This setting has no relation with the `automatic_installation` setting. - ensure_installed = servers, - - -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed. - -- This setting has no relation with the `ensure_installed` setting. - -- Can either be: - -- - false: Servers are not automatically installed. - -- - true: All servers set up via lspconfig are automatically installed. - -- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed. - -- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } } - automatic_installation = true -}) +return { -- LSP - Quickstart configs for Nvim LSP +{ + "neovim/nvim-lspconfig", + event = {"BufReadPre", "BufNewFile"}, + lazy = true, + dependencies = { -- Mason + -- Portable package manager for Neovim that runs everywhere Neovim runs. + -- Easily install and manage LSP servers, DAP servers, linters, and formatters. + {"williamboman/mason.nvim"}, {"williamboman/mason-lspconfig.nvim"}, -- Autocomplete + -- A completion plugin for neovim coded in Lua. + { + "hrsh7th/nvim-cmp", + dependencies = {"L3MON4D3/LuaSnip", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-path", "hrsh7th/cmp-buffer", + "saadparwaiz1/cmp_luasnip"} + }}, + opts = { + -- Automatically format on save + autoformat = true, + -- options for vim.lsp.buf.format + -- `bufnr` and `filter` is handled by the LazyVim formatter, + -- but can be also overridden when specified + format = { + formatting_options = nil, + timeout_ms = nil + }, + -- LSP Server Settings + ---@type lspconfig.options + servers = { + jsonls = {}, + dockerls = {}, + bashls = {}, + gopls = {}, + pyright = {}, + vimls = {}, + yamlls = {} + }, + -- you can do any additional lsp server setup here + -- return true if you don"t want this server to be setup with lspconfig + ---@type table + setup = { + -- example to setup with typescript.nvim + -- tsserver = function(_, opts) + -- require("typescript").setup({ server = opts }) + -- return true + -- end, + -- Specify * to use this function as a fallback for any server + -- ["*"] = function(server, opts) end, + } + }, + ---@param opts Opts + config = function(_, opts) + local servers = opts.servers + local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) --- Add additional capabilities supported by nvim-cmp -local capabilities = require("cmp_nvim_lsp").default_capabilities() + local function setup(server) + local server_opts = vim.tbl_deep_extend("force", { + capabilities = vim.deepcopy(capabilities) + }, servers[server] or {}) -local lspconfig = require('lspconfig') + if opts.setup[server] then + if opts.setup[server](server, server_opts) then + return + end + elseif opts.setup["*"] then + if opts.setup["*"](server, server_opts) then + return + end + end + require("lspconfig")[server].setup(server_opts) + end -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - -- on_attach = my_custom_on_attach, - capabilities = capabilities - } -end + -- temp fix for lspconfig rename + -- https://github.com/neovim/nvim-lspconfig/pull/2439 + local mappings = require("mason-lspconfig.mappings.server") + if not mappings.lspconfig_to_package.lua_ls then + mappings.lspconfig_to_package.lua_ls = "lua-language-server" + mappings.package_to_lspconfig["lua-language-server"] = "lua_ls" + end --- luasnip setup -local luasnip = require 'luasnip' + local mlsp = require("mason-lspconfig") + local available = mlsp.get_available_servers() --- nvim-cmp setup -local cmp = require 'cmp' -cmp.setup { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - 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 = 'path' - }, { - name = 'buffer', - option = { - -- Avoid accidentally running on big files - get_bufnrs = function() - local buf = vim.api.nvim_get_current_buf() - local byte_size = vim.api.nvim_buf_get_offset(buf, vim.api.nvim_buf_line_count(buf)) - if byte_size > 1024 * 1024 then -- 1 Megabyte max - return {} + local ensure_installed = {} ---@type string[] + for server, server_opts in pairs(servers) do + if server_opts then + server_opts = server_opts == true and {} or server_opts + -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig + if server_opts.mason == false or not vim.tbl_contains(available, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server end - return {buf} end + end + + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = ensure_installed, + automatic_installation = true + }) + require("mason-lspconfig").setup_handlers({setup}) + + -- luasnip setup + local luasnip = require "luasnip" + + -- nvim-cmp setup + local cmp = require "cmp" + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true + }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + 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 = "path" + }, { + name = "buffer", + option = { + -- Avoid accidentally running on big files + get_bufnrs = function() + local buf = vim.api.nvim_get_current_buf() + local byte_size = vim.api.nvim_buf_get_offset(buf, vim.api.nvim_buf_line_count(buf)) + if byte_size > 1024 * 1024 then -- 1 Megabyte max + return {} + end + return {buf} + end + } + }} } - }} -} + end +}, -- Use Neovim as a language server to inject LSP diagnostics, +-- code actions, and more via Lua. +{ + "jose-elias-alvarez/null-ls.nvim", + dependencies = {"williamboman/mason.nvim", "nvim-lua/plenary.nvim"}, + lazy = false, + config = function() + local null_ls = require("null-ls") + -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting + local formatting = null_ls.builtins.formatting + -- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics + local diagnostics = null_ls.builtins.diagnostics + + null_ls.setup({ + debug = false, + sources = {formatting.prettier.with { + extra_filetypes = {"toml"}, + extra_args = {"--no-semi", "--single-quote", "--jsx-single-quote"} + }, formatting.black.with { + extra_args = {"--fast"} + }, formatting.stylua, formatting.google_java_format, diagnostics.flake8} + }) + end +}} diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..5c1bbd9 --- /dev/null +++ b/nvim/lua/plugins/lualine.lua @@ -0,0 +1,333 @@ +-- +-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ +-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ +-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ +-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ +-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ +-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +-- +-- File: plugins/lualine.lua +-- Description: Pacman config for lualine +-- Author: Kien Nguyen-Tuan +-- Credit: shadmansaleh & his evil theme: https://github.com/nvim-lualine/lualine.nvim/blob/master/examples/evil_lualine.lua +return { -- Statusline +-- A blazing fast and easy to configure neovim statusline plugin written in pure lua. +{ + "nvim-lualine/lualine.nvim", + config = function(_) + local lualine = require("lualine") + local lualine_require = require("lualine_require") + + function loadcolors() + -- Rose-pine palette + local rosepine = require("rose-pine.palette") + local colors = { + bg = rosepine.base, + fg = rosepine.text, + yellow = rosepine.gold, + cyan = rosepine.foam, + black = rosepine.subtled, + green = rosepine.pine, + white = rosepine.text, + magenta = rosepine.iris, + blue = rosepine.rose, + red = rosepine.love + } + + -- Try to load pywal colors + local modules = lualine_require.lazy_require { + utils_notices = "lualine.utils.notices" + } + local sep = package.config:sub(1, 1) + local wal_colors_path = table.concat({os.getenv("HOME"), ".cache", "wal", "colors.sh"}, sep) + local wal_colors_file = io.open(wal_colors_path, "r") + + if wal_colors_file == nil then + modules.utils_notices.add_notice("lualine.nvim: " .. wal_colors_path .. " not found") + return colors + end + + local ok, wal_colors_text = pcall(wal_colors_file.read, wal_colors_file, "*a") + wal_colors_file:close() + + if not ok then + modules.utils_notices.add_notice("lualine.nvim: " .. wal_colors_path .. " could not be read: " .. + wal_colors_text) + return colors + end + + local wal = {} + + for line in vim.gsplit(wal_colors_text, "\n") do + if line:match("^[a-z0-9]+='#[a-fA-F0-9]+'$") ~= nil then + local i = line:find("=") + local key = line:sub(0, i - 1) + local value = line:sub(i + 2, #line - 1) + wal[key] = value + end + end + + -- Color table for highlights + colors = { + bg = wal.background, + fg = wal.foreground, + yellow = wal.color3, + cyan = wal.color4, + black = wal.color0, + green = wal.color2, + white = wal.color7, + magenta = wal.color5, + blue = wal.color6, + red = wal.color1 + } + + return colors + end + + local colors = loadcolors() + + local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand("%:p:h") + local gitdir = vim.fn.finddir(".git", filepath .. ";") + return gitdir and #gitdir > 0 and #gitdir < #filepath + end + } + + -- Config + local config = { + options = { + -- Disable sections and component separators + component_separators = "", + section_separators = "", + disabled_filetypes = {"packer", "NvimTree"}, + theme = { + -- We are going to use lualine_c an lualine_x as left and + -- right section. Both are highlighted by c theme . So we + -- are just setting default looks o statusline + normal = { + c = { + fg = colors.fg, + bg = colors.bg + } + }, + inactive = { + c = { + fg = colors.fg, + bg = colors.bg + } + } + } + }, + sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + -- These will be filled later + lualine_c = {}, + lualine_x = {} + }, + inactive_sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {} + } + } + + -- Inserts a component in lualine_c at left section + local function ins_left(component) + table.insert(config.sections.lualine_c, component) + end + + -- Inserts a component in lualine_x ot right section + local function ins_right(component) + table.insert(config.sections.lualine_x, component) + end + + ins_left { + -- mode component + function() + return "" + end, + color = function() + -- auto change color according to neovims mode + local mode_color = { + n = colors.red, + i = colors.green, + v = colors.blue, + [""] = colors.blue, + V = colors.blue, + c = colors.magenta, + no = colors.red, + s = colors.yellow, + S = colors.yellow, + [""] = colors.yellow, + ic = colors.yellow, + R = colors.white, + Rv = colors.white, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ["r?"] = colors.cyan, + ["!"] = colors.red, + t = colors.red + } + return { + fg = mode_color[vim.fn.mode()] + } + end, + padding = { + left = 1, + right = 1 + } + } + + ins_left { + "filename", + cond = conditions.buffer_not_empty, + color = { + fg = colors.magenta, + gui = "bold" + } + } + + ins_left { + "branch", + icon = "", + color = { + fg = colors.blue, + gui = "bold" + } + } + + ins_left { + "diff", + -- Is it me or the symbol for modified us really weird + symbols = { + added = " ", + modified = " ", + removed = " " + }, + diff_color = { + added = { + fg = colors.green + }, + modified = { + fg = colors.yellow + }, + removed = { + fg = colors.red + } + }, + cond = conditions.hide_in_width, + padding = { + left = 1, + right = 1 + } + } + + -- Insert mid section. You can make any number of sections in neovim :) + -- for lualine it"s any number greater then 2 + ins_left {function() + return "%=" + end} + + ins_right { + -- Lsp server name . + function() + local msg = "null" + local buf_ft = vim.api.nvim_buf_get_option(0, "filetype") + local clients = vim.lsp.get_active_clients() + if next(clients) == nil then + return msg + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + return client.name + end + end + return msg + end, + icon = " LSP:", + color = { + fg = colors.cyan, + gui = "bold" + } + } + + ins_right { + "diagnostics", + sources = {"nvim_diagnostic"}, + symbols = { + error = " ", + warn = " ", + info = " " + }, + diagnostics_color = { + color_error = { + fg = colors.red + }, + color_warn = { + fg = colors.yellow + }, + color_info = { + fg = colors.cyan + } + }, + always_visible = true + } + + ins_right { + "o:encoding", -- option component same as &encoding in viml + fmt = string.upper, + cond = conditions.hide_in_width, + color = { + fg = colors.green, + gui = "bold" + } + } + + ins_right { + "fileformat", + fmt = string.upper, + icons_enabled = false, + color = { + fg = colors.green, + gui = "bold" + } + } + + ins_right { + "location", + color = { + fg = colors.fg, + gui = "bold" + } + } + + ins_right { + "progress", + color = { + fg = colors.fg, + gui = "bold" + } + } + + -- Now don"t forget to initialize lualine + lualine.setup(config) + end +}} diff --git a/nvim/lua/plugins/term.lua b/nvim/lua/plugins/neoterm.lua similarity index 68% rename from nvim/lua/plugins/term.lua rename to nvim/lua/plugins/neoterm.lua index d6529ed..b44bee5 100644 --- a/nvim/lua/plugins/term.lua +++ b/nvim/lua/plugins/neoterm.lua @@ -6,12 +6,18 @@ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- --- File: plugins/term.lua +-- File: plugins/neoterm.lua -- Description: Floating terminal configs -- Author: Kien Nguyen-Tuan -require('neoterm').setup({ - clear_on_run = true, -- run clear command before user specified commands - mode = 'horizontal', -- vertical/horizontal/fullscreen - noinsert = false -- disable entering insert mode when opening the neoterm window -}) - +return { -- Floating terminal +{ + "itmecho/neoterm.nvim", + opts = { + clear_on_run = true, -- run clear command before user specified commands + mode = "horizontal", -- vertical/horizontal/fullscreen + noinsert = false -- disable entering insert mode when opening the neoterm window + }, + config = function(_, opts) + require("neoterm").setup(opts) + end +}} diff --git a/nvim/lua/plugins/null-ls.lua b/nvim/lua/plugins/null-ls.lua deleted file mode 100644 index 62f7b9f..0000000 --- a/nvim/lua/plugins/null-ls.lua +++ /dev/null @@ -1,26 +0,0 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: plugins/null-ls.lua --- Description: null-ls configuration --- Author: Kien Nguyen-Tuan -local null_ls = require('null-ls') --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting -local formatting = null_ls.builtins.formatting --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics -local diagnostics = null_ls.builtins.diagnostics - -null_ls.setup({ - debug = false, - sources = {formatting.prettier.with { - extra_filetypes = {"toml"}, - extra_args = {"--no-semi", "--single-quote", "--jsx-single-quote"} - }, formatting.black.with { - extra_args = {"--fast"} - }, formatting.stylua, formatting.google_java_format, diagnostics.flake8} -}) diff --git a/nvim/lua/plugins/nvim-autopairs.lua b/nvim/lua/plugins/nvim-autopairs.lua deleted file mode 100644 index 3cfe34f..0000000 --- a/nvim/lua/plugins/nvim-autopairs.lua +++ /dev/null @@ -1,33 +0,0 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: plugins/lualine.lua --- Description: nvim-autopairs config --- Author: Kien Nguyen-Tuan -local npairs = require('nvim-autopairs') - -npairs.setup({ - check_ts = true, - ts_config = { - lua = {'string'}, -- it will not add a pair on that treesitter node - javascript = {'template_string'}, - java = false -- don't check treesitter on java - }, - - -- Don't add pairs if it already has a close pair in the same line - enable_check_bracket_line = false, - - -- Don't add pairs if the next char is alphanumeric - ignored_next_char = "[%w%.]", -- will ignore alphanumeric and `.` symbol - fast_wrap = {}, - disable_filetype = { 'TelescopePrompt', 'vim' }, -}) - -local cmp_autopairs = require('nvim-autopairs.completion.cmp') -local cmp = require('cmp') -cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) diff --git a/nvim/lua/plugins/nvim-treesitter.lua b/nvim/lua/plugins/nvim-treesitter.lua deleted file mode 100644 index 1bc2260..0000000 --- a/nvim/lua/plugins/nvim-treesitter.lua +++ /dev/null @@ -1,38 +0,0 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: plugins/nvim-treesitter.lua --- Description: nvim-treesitter configuration --- Author: Kien Nguyen-Tuan -require('nvim-treesitter.configs').setup { - -- A list of parser names, or 'all' - ensure_installed = {'go', 'python', 'dockerfile', 'json', 'yaml', 'markdown', 'html', 'scss', 'css', 'vim'}, - - highlight = { - enable = true, - use_languagetree = true - }, - indent = { - enable = true - }, - autotag = { - enable = true - }, - context_commentstring = { - enable = true, - enable_autocmd = false - }, - refactor = { - highlight_definitions = { - enable = true - }, - highlight_current_scope = { - enable = false - } - } -} diff --git a/nvim/lua/plugins/statusline.lua b/nvim/lua/plugins/statusline.lua deleted file mode 100644 index 1906680..0000000 --- a/nvim/lua/plugins/statusline.lua +++ /dev/null @@ -1,326 +0,0 @@ --- --- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ --- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ --- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ --- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ --- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ --- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ --- --- File: plugins/lualine.lua --- Description: Pacman config for lualine --- Author: Kien Nguyen-Tuan --- Credit: shadmansaleh & his evil theme: https://github.com/nvim-lualine/lualine.nvim/blob/master/examples/evil_lualine.lua -local lualine = require('lualine') -local lualine_require = require('lualine_require') - -function loadcolors() - -- Rose-pine palette - local rosepine = require('rose-pine.palette') - local colors = { - bg = rosepine.base, - fg = rosepine.text, - yellow = rosepine.gold, - cyan = rosepine.foam, - black = rosepine.subtled, - green = rosepine.pine, - white = rosepine.text, - magenta = rosepine.iris, - blue = rosepine.rose, - red = rosepine.love - } - - -- Try to load pywal colors - local modules = lualine_require.lazy_require { - utils_notices = 'lualine.utils.notices' - } - local sep = package.config:sub(1, 1) - local wal_colors_path = table.concat({os.getenv('HOME'), '.cache', 'wal', 'colors.sh'}, sep) - local wal_colors_file = io.open(wal_colors_path, 'r') - - if wal_colors_file == nil then - modules.utils_notices.add_notice('lualine.nvim: ' .. wal_colors_path .. ' not found') - return colors - end - - local ok, wal_colors_text = pcall(wal_colors_file.read, wal_colors_file, '*a') - wal_colors_file:close() - - if not ok then - modules.utils_notices.add_notice('lualine.nvim: ' .. wal_colors_path .. ' could not be read: ' .. - wal_colors_text) - return colors - end - - local wal = {} - - for line in vim.gsplit(wal_colors_text, '\n') do - if line:match("^[a-z0-9]+='#[a-fA-F0-9]+'$") ~= nil then - local i = line:find('=') - local key = line:sub(0, i - 1) - local value = line:sub(i + 2, #line - 1) - wal[key] = value - end - end - - -- Color table for highlights - colors = { - bg = wal.background, - fg = wal.foreground, - yellow = wal.color3, - cyan = wal.color4, - black = wal.color0, - green = wal.color2, - white = wal.color7, - magenta = wal.color5, - blue = wal.color6, - red = wal.color1 - } - - return colors -end - -local colors = loadcolors() - -local conditions = { - buffer_not_empty = function() - return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 - end, - hide_in_width = function() - return vim.fn.winwidth(0) > 80 - end, - check_git_workspace = function() - local filepath = vim.fn.expand('%:p:h') - local gitdir = vim.fn.finddir('.git', filepath .. ';') - return gitdir and #gitdir > 0 and #gitdir < #filepath - end -} - --- Config -local config = { - options = { - -- Disable sections and component separators - component_separators = '', - section_separators = '', - disabled_filetypes = {'packer', 'NvimTree'}, - theme = { - -- We are going to use lualine_c an lualine_x as left and - -- right section. Both are highlighted by c theme . So we - -- are just setting default looks o statusline - normal = { - c = { - fg = colors.fg, - bg = colors.bg - } - }, - inactive = { - c = { - fg = colors.fg, - bg = colors.bg - } - } - } - }, - sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - -- These will be filled later - lualine_c = {}, - lualine_x = {} - }, - inactive_sections = { - -- these are to remove the defaults - lualine_a = {}, - lualine_b = {}, - lualine_y = {}, - lualine_z = {}, - lualine_c = {}, - lualine_x = {} - } -} - --- Inserts a component in lualine_c at left section -local function ins_left(component) - table.insert(config.sections.lualine_c, component) -end - --- Inserts a component in lualine_x ot right section -local function ins_right(component) - table.insert(config.sections.lualine_x, component) -end - -ins_left { - -- mode component - function() - return '' - end, - color = function() - -- auto change color according to neovims mode - local mode_color = { - n = colors.red, - i = colors.green, - v = colors.blue, - [''] = colors.blue, - V = colors.blue, - c = colors.magenta, - no = colors.red, - s = colors.yellow, - S = colors.yellow, - [''] = colors.yellow, - ic = colors.yellow, - R = colors.white, - Rv = colors.white, - cv = colors.red, - ce = colors.red, - r = colors.cyan, - rm = colors.cyan, - ['r?'] = colors.cyan, - ['!'] = colors.red, - t = colors.red - } - return { - fg = mode_color[vim.fn.mode()] - } - end, - padding = { - left = 1, - right = 1 - } -} - -ins_left { - 'filename', - cond = conditions.buffer_not_empty, - color = { - fg = colors.magenta, - gui = 'bold' - } -} - -ins_left { - 'branch', - icon = '', - color = { - fg = colors.blue, - gui = 'bold' - } -} - -ins_left { - 'diff', - -- Is it me or the symbol for modified us really weird - symbols = { - added = ' ', - modified = ' ', - removed = ' ' - }, - diff_color = { - added = { - fg = colors.green - }, - modified = { - fg = colors.yellow - }, - removed = { - fg = colors.red - } - }, - cond = conditions.hide_in_width, - padding = { - left = 1, - right = 1 - } -} - --- Insert mid section. You can make any number of sections in neovim :) --- for lualine it's any number greater then 2 -ins_left {function() - return '%=' -end} - -ins_right { - -- Lsp server name . - function() - local msg = 'null' - local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') - local clients = vim.lsp.get_active_clients() - if next(clients) == nil then - return msg - end - for _, client in ipairs(clients) do - local filetypes = client.config.filetypes - if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return client.name - end - end - return msg - end, - icon = ' LSP:', - color = { - fg = colors.cyan, - gui = 'bold' - } -} - -ins_right { - 'diagnostics', - sources = {'nvim_diagnostic'}, - symbols = { - error = ' ', - warn = ' ', - info = ' ' - }, - diagnostics_color = { - color_error = { - fg = colors.red - }, - color_warn = { - fg = colors.yellow - }, - color_info = { - fg = colors.cyan - } - }, - always_visible = true -} - -ins_right { - 'o:encoding', -- option component same as &encoding in viml - fmt = string.upper, - cond = conditions.hide_in_width, - color = { - fg = colors.green, - gui = 'bold' - } -} - -ins_right { - 'fileformat', - fmt = string.upper, - icons_enabled = false, - color = { - fg = colors.green, - gui = 'bold' - } -} - -ins_right { - 'location', - color = { - fg = colors.fg, - gui = 'bold' - } -} - -ins_right { - 'progress', - color = { - fg = colors.fg, - gui = 'bold' - } -} - --- Now don't forget to initialize lualine -lualine.setup(config) diff --git a/nvim/lua/plugins/nvim-telescope.lua b/nvim/lua/plugins/telescope.lua similarity index 63% rename from nvim/lua/plugins/nvim-telescope.lua rename to nvim/lua/plugins/telescope.lua index a6d435d..8be0cdb 100644 --- a/nvim/lua/plugins/nvim-telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -6,10 +6,21 @@ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- --- File: plugins/nvim-telescope.lua +-- File: plugins/telescope.lua -- Description: nvim-telescope config -- Author: Kien Nguyen-Tuan -require('telescope').setup() --- To get fzf loaded and working with telescope, you need to call --- load_extension, somewhere after setup function: -require('telescope').load_extension('fzf') +return { -- Telescope +-- Find, Filter, Preview, Pick. All lua, all the time. +{ + "nvim-telescope/telescope.nvim", + dependencies = {"nvim-lua/plenary.nvim", { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make" + }}, + config = function(_) + require("telescope").setup() + -- To get fzf loaded and working with telescope, you need to call + -- load_extension, somewhere after setup function: + require("telescope").load_extension("fzf") + end +}} diff --git a/nvim/lua/plugins/nvim-tree.lua b/nvim/lua/plugins/tree.lua similarity index 77% rename from nvim/lua/plugins/nvim-tree.lua rename to nvim/lua/plugins/tree.lua index 64c4de8..0ed43f8 100644 --- a/nvim/lua/plugins/nvim-tree.lua +++ b/nvim/lua/plugins/tree.lua @@ -6,15 +6,18 @@ -- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ -- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ -- --- File: plugins/nvim-tree.lua +-- File: plugins/tree.lua -- Description: nvim-tree config -- Author: Kien Nguyen-Tuan -- disable netrw at the very start of your init.lua (strongly advised) -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 - --- set termguicolors to enable highlight groups -vim.opt.termguicolors = true - --- empty setup using defaults -require("nvim-tree").setup() +return { -- File explore +-- nvim-tree.lua - A file explorer tree for neovim written in lua +{ + "nvim-tree/nvim-tree.lua", + dependencies = { + "nvim-tree/nvim-web-devicons", + lazy = true, + opt = true + }, + config = true +}} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..d7a386b --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,68 @@ +-- +-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ +-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ +-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ +-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ +-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ +-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +-- +-- File: plugins/treesitter.lua +-- Description: nvim-treesitter configuration +-- Author: Kien Nguyen-Tuan +return { -- Treesitter interface +{ + "nvim-treesitter/nvim-treesitter", + version = false, -- last release is way too old and doesn"t work on Windows + build = ":TSUpdate", + dependencies = {{ + "nvim-treesitter/nvim-treesitter-textobjects", + init = function() + -- PERF: no need to load the plugin, if we only need its queries for mini.ai + local plugin = require("lazy.core.config").spec.plugins["nvim-treesitter"] + local opts = require("lazy.core.plugin").values(plugin, "opts", false) + local enabled = false + if opts.textobjects then + for _, mod in ipairs({"move", "select", "swap", "lsp_interop"}) do + if opts.textobjects[mod] and opts.textobjects[mod].enable then + enabled = true + break + end + end + end + if not enabled then + require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") + end + end + }}, + opts = { + -- A list of parser names, or "all" + ensure_installed = {"go", "python", "dockerfile", "json", "yaml", "markdown", "html", "scss", "css", "vim"}, + + highlight = { + enable = true, + use_languagetree = true + }, + indent = { + enable = true + }, + autotag = { + enable = true + }, + context_commentstring = { + enable = true, + enable_autocmd = false + }, + refactor = { + highlight_definitions = { + enable = true + }, + highlight_current_scope = { + enable = false + } + } + }, + ---@param opts TSConfig + config = function(_, opts) + require("nvim-treesitter.configs").setup(opts) + end +}} diff --git a/screenshots/nvim1.png b/screenshots/nvim1.png index 24b3553..ce7f883 100644 Binary files a/screenshots/nvim1.png and b/screenshots/nvim1.png differ diff --git a/screenshots/nvim2.png b/screenshots/nvim2.png index 1c9b97c..423e0c6 100644 Binary files a/screenshots/nvim2.png and b/screenshots/nvim2.png differ diff --git a/screenshots/nvim3.png b/screenshots/nvim3.png index b11f8cc..fa6b9d7 100644 Binary files a/screenshots/nvim3.png and b/screenshots/nvim3.png differ diff --git a/screenshots/nvim4.png b/screenshots/nvim4.png index 91eccb9..b3d7d1e 100644 Binary files a/screenshots/nvim4.png and b/screenshots/nvim4.png differ diff --git a/screenshots/nvim5.png b/screenshots/nvim5.png index c55392f..784af17 100644 Binary files a/screenshots/nvim5.png and b/screenshots/nvim5.png differ diff --git a/screenshots/nvim6.png b/screenshots/nvim6.png new file mode 100644 index 0000000..53e38a2 Binary files /dev/null and b/screenshots/nvim6.png differ