-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ntk148v/lazy.nvim
Migrate to Lazy.nvim as plugin manager
- Loading branch information
Showing
31 changed files
with
1,035 additions
and
1,021 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
-- | ||
-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ | ||
-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ | ||
-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ | ||
-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ | ||
-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ | ||
-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ | ||
-- | ||
-- File: init.lua | ||
-- Description: main configuration file | ||
-- Author: Kien Nguyen-Tuan <[email protected]> | ||
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ | ||
-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ | ||
-- | ||
-- File: core/autocmds.lua | ||
-- File: config/autocmds.lua | ||
-- Description: Autocommand functions | ||
-- Author: Kien Nguyen-Tuan <[email protected]> | ||
-- 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- | ||
-- ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ | ||
-- ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ | ||
-- ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ | ||
-- ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ | ||
-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ | ||
-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ | ||
-- | ||
-- File: config/init.lua | ||
-- Description: Main configurations | ||
-- Author: Kien Nguyen-Tuan <[email protected]> | ||
-- 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 | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,36 +6,36 @@ | |
-- ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ | ||
-- ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ | ||
-- | ||
-- File: core/keymaps.lua | ||
-- File: config/keymaps.lua | ||
-- Description: Key mapping configs | ||
-- Author: Kien Nguyen-Tuan <[email protected]> | ||
vim.g.mapleader = ' ' | ||
vim.g.mapleader = " " | ||
-- Close all windows and exit from Neovim with <leader> and q | ||
vim.keymap.set('n', '<leader>q', ':qa!<CR>', {}) | ||
vim.keymap.set("n", "<leader>q", ":qa!<CR>", {}) | ||
-- Fast saving with <leader> and s | ||
vim.keymap.set('n', '<leader>s', ':w<CR>', {}) | ||
vim.keymap.set("n", "<leader>s", ":w<CR>", {}) | ||
-- Move around splits | ||
vim.keymap.set('n', '<leader>wh', '<C-w>h', {}) | ||
vim.keymap.set('n', '<leader>wj', '<C-w>j', {}) | ||
vim.keymap.set('n', '<leader>wk', '<C-w>k', {}) | ||
vim.keymap.set('n', '<leader>wl', '<C-w>l', {}) | ||
vim.keymap.set("n", "<leader>wh", "<C-w>h", {}) | ||
vim.keymap.set("n", "<leader>wj", "<C-w>j", {}) | ||
vim.keymap.set("n", "<leader>wk", "<C-w>k", {}) | ||
vim.keymap.set("n", "<leader>wl", "<C-w>l", {}) | ||
|
||
-- Reload configuration without restart nvim | ||
vim.keymap.set('n', '<leader>r', ':so %<CR>', {}) | ||
vim.keymap.set("n", "<leader>r", ":so %<CR>", {}) | ||
|
||
-- Telescope | ||
-- <leader> is a space now | ||
local builtin = require('telescope.builtin') | ||
vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) | ||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) | ||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) | ||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) | ||
local builtin = require("telescope.builtin") | ||
vim.keymap.set("n", "<leader>ff", builtin.find_files, {}) | ||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {}) | ||
vim.keymap.set("n", "<leader>fb", builtin.buffers, {}) | ||
vim.keymap.set("n", "<leader>fh", builtin.help_tags, {}) | ||
|
||
-- NvimTree | ||
vim.keymap.set('n', '<leader>n', ':NvimTreeToggle<CR>', {}) -- open/close | ||
vim.keymap.set('n', '<leader>nr', ':NvimTreeRefresh<CR>', {}) -- refresh | ||
vim.keymap.set('n', '<leader>nf', ':NvimTreeFindFile<CR>', {}) -- search file | ||
vim.keymap.set("n", "<leader>n", ":NvimTreeToggle<CR>", {}) -- open/close | ||
vim.keymap.set("n", "<leader>nr", ":NvimTreeRefresh<CR>", {}) -- refresh | ||
vim.keymap.set("n", "<leader>nf", ":NvimTreeFindFile<CR>", {}) -- search file | ||
|
||
-- Terminal | ||
vim.keymap.set('n', '<leader>tt', ':NeotermToggle<CR>', {}) | ||
-- vim.keymap.set('n', '<leader>tx', ':NeotermExit<CR>', {}) | ||
vim.keymap.set("n", "<leader>tt", ":NeotermToggle<CR>", {}) | ||
-- vim.keymap.set("n", "<leader>tx", ":NeotermExit<CR>", {}) |
Oops, something went wrong.