mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
10 Commits
86e3b29730
...
208b190a65
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
208b190a65 | ||
|
|
602254a881 | ||
|
|
7022eefe22 | ||
|
|
dee7768162 | ||
|
|
22b33871ef | ||
|
|
aab74751f4 | ||
|
|
5dbe643ea2 | ||
|
|
b41998828d | ||
|
|
3670a19e51 | ||
|
|
545c6f4b92 |
@ -74,7 +74,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
|
||||
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
||||
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
|
||||
+ Color theme via [vim-gruvbox8](https://github.com/lifepillar/vim-gruvbox8) and other beautiful themes.
|
||||
+ Beautiful colorscheme via [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) and other colorschemes.
|
||||
+ Markdown writing and previewing via [vim-markdown](https://github.com/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
||||
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
|
||||
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
--- This module will load a random colorscheme on nvim startup process.
|
||||
|
||||
local utils = require('utils')
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Theme to directory name mapping, because theme repo name is not necessarily
|
||||
-- the same as the theme name itself.
|
||||
M.theme2dir = {
|
||||
-- Colorscheme to its directory name mapping, because colorscheme repo name is not necessarily
|
||||
-- the same as the colorscheme name itself.
|
||||
M.colorscheme2dir = {
|
||||
gruvbox8 = "vim-gruvbox8",
|
||||
onedark = 'onedark.nvim',
|
||||
edge = 'edge',
|
||||
@ -89,35 +91,36 @@ M.catppuccin = function()
|
||||
end
|
||||
|
||||
|
||||
--- Use a random theme from the pre-defined list of themes.
|
||||
M.rand_theme = function ()
|
||||
local theme = utils.rand_element(vim.tbl_keys(M.theme2dir))
|
||||
--- Use a random colorscheme from the pre-defined list of colorschemes.
|
||||
M.rand_colorscheme = function ()
|
||||
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme2dir))
|
||||
|
||||
if not vim.tbl_contains(vim.tbl_keys(M), theme) then
|
||||
local msg = "Invalid theme: " .. theme
|
||||
if not vim.tbl_contains(vim.tbl_keys(M), colorscheme) then
|
||||
local msg = "Invalid colorscheme: " .. colorscheme
|
||||
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- Load the theme, because all the themes are declared as opt plugins, the theme isn't loaded yet.
|
||||
local status = utils.add_pack(M.theme2dir[theme])
|
||||
-- Load the colorscheme, because all the colorschemes are declared as opt plugins, so the colorscheme isn't loaded yet.
|
||||
local status = utils.add_pack(M.colorscheme2dir[colorscheme])
|
||||
|
||||
if not status then
|
||||
local msg = string.format("Theme %s is not installed. Run PackerSync to install.", theme)
|
||||
local msg = string.format("Colorscheme %s is not installed. Run PackerSync to install.", colorscheme)
|
||||
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- Set the theme.
|
||||
M[theme]()
|
||||
-- Load the colorscheme and its settings
|
||||
M[colorscheme]()
|
||||
|
||||
if vim.g.logging_level == 'debug' then
|
||||
local msg = "Colorscheme: " .. theme
|
||||
local msg = "Colorscheme: " .. colorscheme
|
||||
|
||||
vim.notify(msg, vim.log.levels.DEBUG, { title = 'nvim-config' })
|
||||
end
|
||||
end
|
||||
|
||||
M.rand_theme()
|
||||
-- Load a random colorscheme
|
||||
M.rand_colorscheme()
|
||||
@ -1,7 +1,7 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
" Plugin specification and lua stuff
|
||||
lua require('lua-init')
|
||||
lua require('plugins')
|
||||
|
||||
" Use short names for common plugin manager commands to simplify typing.
|
||||
" To use these shortcuts: first activate command line with `:`, then input the
|
||||
|
||||
@ -245,6 +245,7 @@ fi
|
||||
|
||||
echo "Setting up config and installing plugins"
|
||||
if [[ -d "$NVIM_CONFIG_DIR" ]]; then
|
||||
rm -rf "$NVIM_CONFIG_DIR.backup"
|
||||
mv "$NVIM_CONFIG_DIR" "$NVIM_CONFIG_DIR.backup"
|
||||
fi
|
||||
|
||||
|
||||
12
init.lua
12
init.lua
@ -21,12 +21,12 @@ if nvim_ver ~= expected_ver then
|
||||
end
|
||||
|
||||
local core_conf_files = {
|
||||
"globals.vim",
|
||||
"options.vim",
|
||||
"autocommands.vim",
|
||||
"mappings.vim",
|
||||
"plugins.vim",
|
||||
"themes.lua",
|
||||
"globals.vim", -- some global settings
|
||||
"options.vim", -- setting options in nvim
|
||||
"autocommands.vim", -- various autocommands
|
||||
"mappings.vim", -- all the user-defined mappings
|
||||
"plugins.vim", -- all the plugins installed and their configurations
|
||||
"colorschemes.lua", -- colorscheme settings
|
||||
}
|
||||
|
||||
-- source all the core config files
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
local api = vim.api
|
||||
|
||||
local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" }
|
||||
require("indent_blankline").setup({
|
||||
-- U+2502 may also be a good choice, it will be on the middle of cursor.
|
||||
-- U+250A is also a good choice
|
||||
@ -5,19 +8,22 @@ require("indent_blankline").setup({
|
||||
show_end_of_line = false,
|
||||
disable_with_nolist = true,
|
||||
buftype_exclude = { "terminal" },
|
||||
filetype_exclude = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" },
|
||||
filetype_exclude = exclude_ft,
|
||||
})
|
||||
|
||||
vim.cmd([[
|
||||
function! Should_activate_indentblankline() abort
|
||||
if index(g:indent_blankline_filetype_exclude, &filetype) == -1
|
||||
IndentBlanklineEnable
|
||||
endif
|
||||
endfunction
|
||||
local gid = api.nvim_create_augroup("indent_blankline", { clear = true })
|
||||
api.nvim_create_autocmd("InsertEnter", {
|
||||
pattern = "*",
|
||||
group = gid,
|
||||
command = "IndentBlanklineDisable"
|
||||
})
|
||||
|
||||
augroup indent_blankline
|
||||
autocmd!
|
||||
autocmd InsertEnter * IndentBlanklineDisable
|
||||
autocmd InsertLeave * call Should_activate_indentblankline()
|
||||
augroup END
|
||||
]])
|
||||
api.nvim_create_autocmd("InsertLeave", {
|
||||
pattern = "*",
|
||||
group = gid,
|
||||
callback = function()
|
||||
if not vim.tbl_contains(exclude_ft, vim.bo.filetype) then
|
||||
vim.cmd [[IndentBlanklineEnable]]
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
@ -34,7 +34,7 @@ cmp.setup({
|
||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||
{ name = 'ultisnips' }, -- For ultisnips user.
|
||||
{ name = 'path' }, -- for path completion
|
||||
{ name = 'buffer', keyword_length = 4 }, -- for buffer word completion
|
||||
{ name = 'buffer', keyword_length = 2 }, -- for buffer word completion
|
||||
{ name = 'omni' },
|
||||
{ name = 'emoji', insert = true, } -- emoji completion
|
||||
},
|
||||
@ -55,7 +55,7 @@ cmp.setup({
|
||||
path = "[Path]",
|
||||
buffer = "[Buffer]",
|
||||
emoji = "[Emoji]",
|
||||
omni = "[Omni]",
|
||||
omni = "[Omni]",
|
||||
}),
|
||||
}),
|
||||
},
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
-- Some utility stuff
|
||||
require 'utils'
|
||||
|
||||
-- plugin installation
|
||||
require 'plugins'
|
||||
Loading…
x
Reference in New Issue
Block a user