mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
6 Commits
v0.10.0
...
bbb8545403
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbb8545403 | ||
|
|
9efadac8fb | ||
|
|
6e137fe9a3 | ||
|
|
719fbfc1ab | ||
|
|
e815de294f | ||
|
|
ca7430056c |
10
README.md
10
README.md
@@ -13,7 +13,7 @@
|
|||||||
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
||||||
<img src="https://img.shields.io/badge/Neovim-0.9.5-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
<img src="https://img.shields.io/badge/Neovim-0.10.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
|
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
|
||||||
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
|
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
<a href="https://github.com/jdhao/nvim-config/graphs/commit-activity">
|
<a href="https://github.com/jdhao/nvim-config/graphs/commit-activity">
|
||||||
<img src="https://img.shields.io/github/commit-activity/m/jdhao/nvim-config?style=flat-square" />
|
<img src="https://img.shields.io/github/commit-activity/m/jdhao/nvim-config?style=flat-square" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/jdhao/nvim-config/releases/tag/v0.9.5">
|
<a href="https://github.com/jdhao/nvim-config/releases/tag/v0.10.0">
|
||||||
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.9.5?style=flat-square" />
|
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.10.0?style=flat-square" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/jdhao/nvim-config/graphs/contributors">
|
<a href="https://github.com/jdhao/nvim-config/graphs/contributors">
|
||||||
<img src="https://img.shields.io/github/contributors/jdhao/nvim-config?style=flat-square" />
|
<img src="https://img.shields.io/github/contributors/jdhao/nvim-config?style=flat-square" />
|
||||||
@@ -169,8 +169,8 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
|
|||||||
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
||||||
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
||||||
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
||||||
| `<leader>gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines
|
| `<leader>gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines |
|
||||||
| `<leader>gb` | Normal | macOS | Browse current git repo in browser
|
| `<leader>gb` | Normal | macOS | Browse current git repo in browser |
|
||||||
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
||||||
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
||||||
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
||||||
|
|||||||
6
init.lua
6
init.lua
@@ -14,11 +14,11 @@ vim.loader.enable()
|
|||||||
local version = vim.version
|
local version = vim.version
|
||||||
|
|
||||||
-- check if we have the latest stable version of nvim
|
-- check if we have the latest stable version of nvim
|
||||||
local expected_ver = "0.10.0"
|
local expected_ver = "0.10.1"
|
||||||
local ev = version.parse(expected_ver)
|
local expect_ver = version.parse(expected_ver)
|
||||||
local actual_ver = version()
|
local actual_ver = version()
|
||||||
|
|
||||||
local result = version.cmp(ev, {actual_ver.major, actual_ver.minor, actual_ver.patch})
|
local result = version.cmp(expect_ver, actual_ver)
|
||||||
|
|
||||||
if result ~= 0 then
|
if result ~= 0 then
|
||||||
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
||||||
|
|||||||
@@ -231,11 +231,12 @@ if utils.executable("lua-language-server") then
|
|||||||
},
|
},
|
||||||
workspace = {
|
workspace = {
|
||||||
-- Make the server aware of Neovim runtime files,
|
-- Make the server aware of Neovim runtime files,
|
||||||
-- see also https://github.com/LuaLS/lua-language-server/wiki/Libraries#link-to-workspace .
|
-- see also https://luals.github.io/wiki/settings/#workspacelibrary
|
||||||
-- Lua-dev.nvim also has similar settings for lua ls, https://github.com/folke/neodev.nvim/blob/main/lua/neodev/luals.lua .
|
|
||||||
library = {
|
library = {
|
||||||
vim.env.VIMRUNTIME,
|
vim.env.VIMRUNTIME,
|
||||||
fn.stdpath("config"),
|
fn.stdpath("config"),
|
||||||
|
-- make lua_ls aware of functions under vim.uv
|
||||||
|
"${3rd}/luv/library"
|
||||||
},
|
},
|
||||||
maxPreload = 2000,
|
maxPreload = 2000,
|
||||||
preloadFileSize = 50000,
|
preloadFileSize = 50000,
|
||||||
|
|||||||
@@ -99,12 +99,12 @@ end
|
|||||||
|
|
||||||
local virtual_env = function()
|
local virtual_env = function()
|
||||||
-- only show virtual env for Python
|
-- only show virtual env for Python
|
||||||
if vim.bo.filetype ~= 'python' then
|
if vim.bo.filetype ~= "python" then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
local conda_env = os.getenv('CONDA_DEFAULT_ENV')
|
local conda_env = os.getenv("CONDA_DEFAULT_ENV")
|
||||||
local venv_path = os.getenv('VIRTUAL_ENV')
|
local venv_path = os.getenv("VIRTUAL_ENV")
|
||||||
|
|
||||||
if venv_path == nil then
|
if venv_path == nil then
|
||||||
if conda_env == nil then
|
if conda_env == nil then
|
||||||
@@ -113,17 +113,32 @@ local virtual_env = function()
|
|||||||
return string.format(" %s (conda)", conda_env)
|
return string.format(" %s (conda)", conda_env)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local venv_name = vim.fn.fnamemodify(venv_path, ':t')
|
local venv_name = vim.fn.fnamemodify(venv_path, ":t")
|
||||||
return string.format(" %s (venv)", venv_name)
|
return string.format(" %s (venv)", venv_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local get_active_lsp = function()
|
||||||
|
local msg = "No Active Lsp"
|
||||||
|
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
|
||||||
|
local clients = vim.lsp.get_clients { bufnr = 0 }
|
||||||
|
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
|
||||||
|
|
||||||
require("lualine").setup {
|
require("lualine").setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
-- component_separators = { left = "", right = "" },
|
|
||||||
-- section_separators = { left = "", right = "" },
|
|
||||||
section_separators = "",
|
section_separators = "",
|
||||||
component_separators = "",
|
component_separators = "",
|
||||||
disabled_filetypes = {},
|
disabled_filetypes = {},
|
||||||
@@ -132,18 +147,29 @@ require("lualine").setup {
|
|||||||
sections = {
|
sections = {
|
||||||
lualine_a = { "mode" },
|
lualine_a = { "mode" },
|
||||||
lualine_b = {
|
lualine_b = {
|
||||||
"branch",
|
{
|
||||||
|
"branch",
|
||||||
|
fmt = function(name, context)
|
||||||
|
-- truncate branch name in case the name is too long
|
||||||
|
return string.sub(name, 1, 20)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
virtual_env,
|
||||||
|
color = { fg = "black", bg = "#F1CA81" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lualine_c = {
|
||||||
|
{
|
||||||
|
"filename",
|
||||||
|
symbols = {
|
||||||
|
readonly = "[🔒]",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"diff",
|
"diff",
|
||||||
source = diff,
|
source = diff,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
virtual_env,
|
|
||||||
color = { fg = 'black', bg = "#F1CA81" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
lualine_c = {
|
|
||||||
"filename",
|
|
||||||
{
|
{
|
||||||
ime_state,
|
ime_state,
|
||||||
color = { fg = "black", bg = "#f46868" },
|
color = { fg = "black", bg = "#f46868" },
|
||||||
@@ -152,13 +178,19 @@ require("lualine").setup {
|
|||||||
spell,
|
spell,
|
||||||
color = { fg = "black", bg = "#a7c080" },
|
color = { fg = "black", bg = "#a7c080" },
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
lualine_x = {
|
||||||
|
{
|
||||||
|
get_active_lsp,
|
||||||
|
icon = " LSP:",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
sources = { "nvim_diagnostic" },
|
sources = { "nvim_diagnostic" },
|
||||||
symbols = {error = '🆇 ', warn = '⚠️ ', info = 'ℹ️ ', hint = ' '},
|
symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_y = {
|
||||||
"encoding",
|
"encoding",
|
||||||
{
|
{
|
||||||
"fileformat",
|
"fileformat",
|
||||||
@@ -170,9 +202,6 @@ require("lualine").setup {
|
|||||||
},
|
},
|
||||||
"filetype",
|
"filetype",
|
||||||
},
|
},
|
||||||
lualine_y = {
|
|
||||||
"location",
|
|
||||||
},
|
|
||||||
lualine_z = {
|
lualine_z = {
|
||||||
{
|
{
|
||||||
trailing_space,
|
trailing_space,
|
||||||
@@ -182,6 +211,7 @@ require("lualine").setup {
|
|||||||
mixed_indent,
|
mixed_indent,
|
||||||
color = "WarningMsg",
|
color = "WarningMsg",
|
||||||
},
|
},
|
||||||
|
"progress"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ end
|
|||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
-- check if firenvim is active
|
-- check if firenvim is active
|
||||||
|
-- macOS will reset the PATH when firenvim starts a nvim process, causing the PATH variable to change unexpectedly.
|
||||||
|
-- Here we are trying to get the correct PATH and use it for firenvim.
|
||||||
|
-- See also https://github.com/glacambre/firenvim/blob/master/TROUBLESHOOTING.md#make-sure-firenvims-path-is-the-same-as-neovims
|
||||||
|
local path_env = vim.env.PATH
|
||||||
|
local prologue = string.format('export PATH="%s"', path_env)
|
||||||
|
|
||||||
local firenvim_not_active = function()
|
local firenvim_not_active = function()
|
||||||
return not vim.g.started_by_firenvim
|
return not vim.g.started_by_firenvim
|
||||||
end
|
end
|
||||||
@@ -122,9 +128,10 @@ local plugin_specs = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lukas-reineke/headlines.nvim",
|
"MeanderingProgrammer/markdown.nvim",
|
||||||
dependencies = "nvim-treesitter/nvim-treesitter",
|
main = "render-markdown",
|
||||||
config = true, -- or `opts = {}`
|
opts = {},
|
||||||
|
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
|
||||||
},
|
},
|
||||||
-- A list of colorscheme plugin you may want to try. Find what suits you.
|
-- A list of colorscheme plugin you may want to try. Find what suits you.
|
||||||
{ "navarasu/onedark.nvim", lazy = true },
|
{ "navarasu/onedark.nvim", lazy = true },
|
||||||
@@ -169,7 +176,7 @@ local plugin_specs = {
|
|||||||
{
|
{
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
main = 'ibl',
|
main = "ibl",
|
||||||
config = function()
|
config = function()
|
||||||
require("config.indent-blankline")
|
require("config.indent-blankline")
|
||||||
end,
|
end,
|
||||||
@@ -222,9 +229,9 @@ local plugin_specs = {
|
|||||||
|
|
||||||
-- Automatic insertion and deletion of a pair of characters
|
-- Automatic insertion and deletion of a pair of characters
|
||||||
{
|
{
|
||||||
'windwp/nvim-autopairs',
|
"windwp/nvim-autopairs",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
config = true
|
config = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Comment plugin
|
-- Comment plugin
|
||||||
@@ -316,7 +323,7 @@ local plugin_specs = {
|
|||||||
{ "rhysd/committia.vim", lazy = true },
|
{ "rhysd/committia.vim", lazy = true },
|
||||||
|
|
||||||
{
|
{
|
||||||
"sindrets/diffview.nvim"
|
"sindrets/diffview.nvim",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -418,17 +425,13 @@ local plugin_specs = {
|
|||||||
{
|
{
|
||||||
"glacambre/firenvim",
|
"glacambre/firenvim",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
if vim.g.is_win or vim.g.is_mac then
|
local result = vim.g.is_win or vim.g.is_mac
|
||||||
return true
|
return result
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
end,
|
||||||
build = function()
|
-- it seems that we can only call the firenvim function directly.
|
||||||
vim.fn["firenvim#install"](0)
|
-- Using vim.fn or vim.cmd to call this function will fail.
|
||||||
end,
|
build = string.format(":call firenvim#install(0, '%s')", prologue),
|
||||||
lazy = true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Debugger plugin
|
-- Debugger plugin
|
||||||
{
|
{
|
||||||
"sakhnik/nvim-gdb",
|
"sakhnik/nvim-gdb",
|
||||||
@@ -494,13 +497,14 @@ local plugin_specs = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- configuration for lazy itself.
|
require("lazy").setup {
|
||||||
local lazy_opts = {
|
spec = plugin_specs,
|
||||||
ui = {
|
ui = {
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
title = "Plugin Manager",
|
title = "Plugin Manager",
|
||||||
title_pos = "center",
|
title_pos = "center",
|
||||||
},
|
},
|
||||||
|
rocks = {
|
||||||
|
enabled = false
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require("lazy").setup(plugin_specs, lazy_opts)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user