1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

2 Commits

Author SHA1 Message Date
WombleWoo7547
7e355bce3b Merge 994b0d4c84 into d715ce8f31 2024-10-12 09:45:44 -04:00
WombleWoo7547
994b0d4c84 Update documentation to mention WSL2 2024-10-06 09:21:22 +01:00
23 changed files with 147 additions and 287 deletions

View File

@@ -191,6 +191,7 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
| `Alt-j` | Normal | Linux/macOS/Win | Move current line or selected lines down |
| `Alt-m` | Normal | macOS/Win | Markdown previewing in system browser |
| `Alt-Shift-m` | Normal | macOS/Win | Stopping Markdown previewing in system browser |
| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection |
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case |
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging |
@@ -205,7 +206,6 @@ In addition to commands provided by various plugins, I have also created some cu
| `Edit` | edit multiple files at the same time, supports globing | `Edit *.vim` |
| `Datetime` | print current date and time or convert Unix time stamp to date and time | `Datetime 12345` or `Datetime` |
| `JSONFormat` | format a JSON file | `JSONFormat` |
| `CopyPath` | copy current file path to clipboard | `CopyPath relative` |
# Contributing

View File

@@ -3,5 +3,3 @@ set formatoptions-=o
set formatoptions-=r
nnoremap <buffer><silent> <F9> :luafile %<CR>
nnoremap <buffer><silent> <space>f <cmd>silent !stylua %<CR>

View File

@@ -10,7 +10,7 @@ For a list of terminals that support true colors, see [here](https://github.com/
For macOS, we can use [kitty](https://sw.kovidgoyal.net/kitty/), [iterm2](https://www.iterm2.com/), [wezterm](https://wezfurlong.org/wezterm/) or [Alacritty](https://github.com/jwilm/alacritty).
If you ssh to Linux server on Windows, I recommend [wsltty](https://github.com/mintty/wsltty) and [Cygwin](https://www.cygwin.com/),
If you ssh to Linux server on Windows, or use [WSL2 (Windows Subsystem for Linux)](https://learn.microsoft.com/en-us/windows/wsl/about) I recommend [wsltty](https://github.com/mintty/wsltty) and [Cygwin](https://www.cygwin.com/),
both of them use [mintty](https://github.com/mintty/mintty) as the terminal emulator.
For the latest version of Windows 10, you can also try [Windows Terminal](https://github.com/microsoft/terminal).

View File

@@ -28,6 +28,6 @@ require("custom-autocmd")
-- all the user-defined mappings
require("mappings")
-- all the plugins installed and their configurations
vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim"))
vim.cmd("source ".. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim"))
-- colorscheme settings
require("colorschemes")

View File

@@ -50,18 +50,18 @@ M.colorscheme_conf = {
end,
onedarkpro = function()
-- set colorscheme after options
vim.cmd("colorscheme onedark_vivid")
vim.cmd('colorscheme onedark_vivid')
end,
material = function()
vim.g.material_style = "oceanic"
vim.cmd("colorscheme material")
vim.cmd('colorscheme material')
end,
arctic = function()
arctic = function ()
vim.cmd("colorscheme arctic")
end,
kanagawa = function()
vim.cmd("colorscheme kanagawa-wave")
end,
end
}
--- Use a random colorscheme from the pre-defined list of colorschemes.

View File

@@ -59,17 +59,17 @@ conf.center = {
},
}
dashboard.setup {
theme = "doom",
shortcut_type = "number",
config = conf,
}
dashboard.setup({
theme = 'doom',
shortcut_type = 'number',
config = conf
})
api.nvim_create_autocmd("FileType", {
pattern = "dashboard",
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
callback = function()
callback = function ()
keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true })
keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true })
end,
end
})

View File

@@ -5,26 +5,16 @@ gitlinker.setup {
callbacks = {
["dev.azure.com"] = function(url_data)
vim.print(url_data)
local url = require("gitlinker.hosts").get_base_https_url(url_data)
local url = require"gitlinker.hosts".get_base_https_url(url_data)
if url_data.lstart then
if url_data.lend == nil then
url_data.lend = url_data.lstart
end
url = url
.. "?path=/"
.. url_data.file
.. "&version=GC"
.. url_data.rev
.. "&line="
.. url_data.lstart
.. "&lineEnd="
.. url_data.lend
.. "&lineStartColumn=1"
.. "&lineEndColumn=120"
url = url .. "?path=/" .. url_data.file .. "&version=GC" .. url_data.rev .. "&line=" .. url_data.lstart .. "&lineEnd=" .. url_data.lend .. "&lineStartColumn=1" .. "&lineEndColumn=120"
end
return url
end,
end
},
mappings = nil,
}
@@ -38,9 +28,9 @@ end, {
})
keymap.set("n", "<leader>gbr", function()
gitlinker.get_repo_url {
action_callback = gitlinker.actions.open_in_browser,
}
gitlinker.get_repo_url({
action_callback = gitlinker.actions.open_in_browser
})
end, {
silent = true,
desc = "Git: browse repo in browser",

View File

@@ -45,13 +45,13 @@ gs.setup {
end,
}
vim.api.nvim_create_autocmd("ColorScheme", {
vim.api.nvim_create_autocmd('ColorScheme', {
pattern = "*",
callback = function()
vim.cmd([[
vim.cmd [[
hi GitSignsChangeInline gui=reverse
hi GitSignsAddInline gui=reverse
hi GitSignsDeleteInline gui=reverse
]])
end,
]]
end
})

View File

@@ -14,7 +14,7 @@ local activate_hlslens = function(direction)
-- Deal with the case that there is no such pattern in current buffer.
if not status then
local start_idx, _ = string.find(msg, "E486", 1, true)
local start_idx, _ = string.find(msg, 'E486', 1, true)
local msg_part = string.sub(msg, start_idx)
api.nvim_err_writeln(msg_part)
return

View File

@@ -3,7 +3,6 @@ local api = vim.api
local keymap = vim.keymap
local lsp = vim.lsp
local diagnostic = vim.diagnostic
local lspconfig = require("lspconfig")
local utils = require("utils")
@@ -13,10 +12,10 @@ local set_qflist = function(buf_num, severity)
diagnostics = diagnostic.get(buf_num, { severity = severity })
local qf_items = diagnostic.toqflist(diagnostics)
vim.fn.setqflist({}, " ", { title = "Diagnostics", items = qf_items })
vim.fn.setqflist({}, ' ', { title = 'Diagnostics', items = qf_items })
-- open quickfix by default
vim.cmd([[copen]])
vim.cmd[[copen]]
end
local custom_attach = function(client, bufnr)
@@ -39,9 +38,7 @@ local custom_attach = function(client, bufnr)
-- this puts diagnostics from opened files to quickfix
map("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
-- this puts diagnostics from current buffer to quickfix
map("n", "<space>qb", function()
set_qflist(bufnr)
end, { desc = "put buffer diagnostics to qf" })
map("n", "<space>qb", function() set_qflist(bufnr) end, { desc = "put buffer diagnostics to qf" })
map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
@@ -50,14 +47,10 @@ local custom_attach = function(client, bufnr)
end, { desc = "list workspace folder" })
-- Set some key bindings conditional on server capabilities
if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then
map({ "n", "x" }, "<space>f", vim.lsp.buf.format, { desc = "format code" })
if client.server_capabilities.documentFormattingProvider then
map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" })
end
-- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
-- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
-- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
@@ -74,9 +67,8 @@ local custom_attach = function(client, bufnr)
end
local cursor_pos = api.nvim_win_get_cursor(0)
if
(cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
and #diagnostic.get() > 0
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
and #diagnostic.get() > 0
then
diagnostic.open_float(nil, float_opts)
end
@@ -94,20 +86,20 @@ local custom_attach = function(client, bufnr)
]])
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
api.nvim_create_autocmd("CursorHold", {
api.nvim_create_autocmd("CursorHold" , {
group = gid,
buffer = bufnr,
callback = function()
callback = function ()
lsp.buf.document_highlight()
end,
end
})
api.nvim_create_autocmd("CursorMoved", {
api.nvim_create_autocmd("CursorMoved" , {
group = gid,
buffer = bufnr,
callback = function()
callback = function ()
lsp.buf.clear_references()
end,
end
})
end
@@ -117,101 +109,70 @@ local custom_attach = function(client, bufnr)
end
end
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- required by nvim-ufo
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
dynamicRegistration = false,
lineFoldingOnly = true
}
-- For what diagnostic is enabled in which type checking mode, check doc:
-- https://github.com/microsoft/pyright/blob/main/docs/configuration.md#diagnostic-settings-defaults
-- Currently, the pyright also has some issues displaying hover documentation:
-- https://www.reddit.com/r/neovim/comments/1gdv1rc/what_is_causeing_the_lsp_hover_docs_to_looks_like/
local lspconfig = require("lspconfig")
if utils.executable("pyright") then
local new_capability = {
-- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
-- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
textDocument = {
publishDiagnostics = {
tagSupport = {
valueSet = { 2 },
},
},
hover = {
contentFormat = { "plaintext" },
dynamicRegistration = true,
},
},
}
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
if utils.executable("pylsp") then
local venv_path = os.getenv('VIRTUAL_ENV')
local py_path = nil
-- decide which python executable to use for mypy
if venv_path ~= nil then
py_path = venv_path .. "/bin/python3"
else
py_path = vim.g.python3_host_prog
end
lspconfig.pyright.setup {
cmd = { "delance-langserver", "--stdio" },
lspconfig.pylsp.setup {
on_attach = custom_attach,
capabilities = merged_capability,
settings = {
pyright = {
-- disable import sorting and use Ruff for this
disableOrganizeImports = true,
disableTaggedHints = false,
},
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = "workspace",
typeCheckingMode = "standard",
useLibraryCodeForTypes = true,
-- we can this setting below to redefine some diagnostics
diagnosticSeverityOverrides = {
deprecateTypingAliases = false,
},
-- inlay hint settings are provided by pylance?
inlayHints = {
callArgumentNames = "partial",
functionReturnTypes = true,
pytestParameters = true,
variableTypes = true,
pylsp = {
plugins = {
-- formatter options
black = { enabled = true },
autopep8 = { enabled = false },
yapf = { enabled = false },
-- linter options
pylint = { enabled = true, executable = "pylint" },
ruff = { enabled = false },
pyflakes = { enabled = false },
pycodestyle = { enabled = false },
-- type checker
pylsp_mypy = {
enabled = true,
overrides = { "--python-executable", py_path, true },
report_progress = true,
live_mode = false
},
-- auto-completion options
jedi_completion = { fuzzy = true },
-- import sorting
isort = { enabled = true },
},
},
},
flags = {
debounce_text_changes = 200,
},
capabilities = capabilities,
}
else
vim.notify("pyright not found!", vim.log.levels.WARN, { title = "Nvim-config" })
vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Nvim-config" })
end
if utils.executable("ruff") then
require("lspconfig").ruff.setup {
on_attach = custom_attach,
capabilities = capabilities,
init_options = {
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
settings = {
organizeImports = true,
},
},
}
end
-- Disable ruff hover feature in favor of Pyright
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
-- vim.print(client.name, client.server_capabilities)
if client == nil then
return
end
if client.name == "ruff" then
client.server_capabilities.hoverProvider = false
end
end,
desc = "LSP: Disable hover capability from Ruff",
})
-- if utils.executable('pyright') then
-- lspconfig.pyright.setup{
-- on_attach = custom_attach,
-- capabilities = capabilities
-- }
-- else
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
-- end
if utils.executable("ltex-ls") then
lspconfig.ltex.setup {
@@ -220,11 +181,11 @@ if utils.executable("ltex-ls") then
filetypes = { "text", "plaintex", "tex", "markdown" },
settings = {
ltex = {
language = "en",
language = "en"
},
},
flags = { debounce_text_changes = 300 },
}
}
end
if utils.executable("clangd") then
@@ -259,8 +220,8 @@ if utils.executable("bash-language-server") then
}
end
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
if utils.executable("lua-language-server") then
-- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
lspconfig.lua_ls.setup {
on_attach = custom_attach,
settings = {
@@ -269,9 +230,6 @@ if utils.executable("lua-language-server") then
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
hint = {
enable = true,
},
},
},
capabilities = capabilities,
@@ -279,10 +237,10 @@ if utils.executable("lua-language-server") then
end
-- Change diagnostic signs.
fn.sign_define("DiagnosticSignError", { text = "🆇", texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = "⚠️", texthl = "DiagnosticSignWarn" })
fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" })
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
fn.sign_define("DiagnosticSignError", { text = '🆇', texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = '⚠️', texthl = "DiagnosticSignWarn" })
fn.sign_define("DiagnosticSignInfo", { text = '', texthl = "DiagnosticSignInfo" })
fn.sign_define("DiagnosticSignHint", { text = '', texthl = "DiagnosticSignHint" })
-- global config for diagnostic
diagnostic.config {

View File

@@ -140,15 +140,13 @@ require("lualine").setup {
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = "",
component_separators = "",
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = {
"mode",
},
lualine_a = { "mode" },
lualine_b = {
{
"branch",
@@ -156,7 +154,6 @@ require("lualine").setup {
-- truncate branch name in case the name is too long
return string.sub(name, 1, 20)
end,
color = { gui = "italic,bold" },
},
{
virtual_env,
@@ -175,8 +172,8 @@ require("lualine").setup {
source = diff,
},
{
"%S",
color = { gui = "bold", fg = "cyan" },
ime_state,
color = { fg = "black", bg = "#f46868" },
},
{
spell,
@@ -184,10 +181,6 @@ require("lualine").setup {
},
},
lualine_x = {
{
ime_state,
color = { fg = "black", bg = "#f46868" },
},
{
get_active_lsp,
icon = " LSP:",
@@ -199,7 +192,7 @@ require("lualine").setup {
},
},
lualine_y = {
{ "encoding", fmt = string.upper },
"encoding",
{
"fileformat",
symbols = {
@@ -219,8 +212,7 @@ require("lualine").setup {
mixed_indent,
color = "WarningMsg",
},
"location",
"progress",
"progress"
},
},
inactive_sections = {

View File

@@ -3,7 +3,7 @@ local ffi = require("statuscol.ffidef")
local C = ffi.C
-- only show fold level up to this level
local fold_level_limit = 3
local fold_level_limit = 2
local function foldfunc(args)
local foldinfo = C.fold_info(args.wp, args.lnum)
if foldinfo.level > fold_level_limit then

View File

@@ -4,7 +4,7 @@ hop.setup {
case_insensitive = true,
char2_fallback_key = "<CR>",
quit_key = "<Esc>",
match_mappings = { "zh_sc" },
match_mappings = { "zh_sc" }
}
keymap.set({ "n", "v", "o" }, "f", "", {
@@ -24,5 +24,5 @@ vim.api.nvim_create_autocmd("ColorScheme", {
hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
]])
end,
end
})

View File

@@ -3,6 +3,6 @@ require("nvim-treesitter.configs").setup {
ignore_install = {}, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension
disable = { "help" }, -- list of language that will be disabled
disable = { 'help' }, -- list of language that will be disabled
},
}

View File

@@ -1,6 +1,6 @@
require("which-key").setup {
preset = "modern",
icons = {
mappings = false,
},
mappings = false
}
}

View File

@@ -165,9 +165,8 @@ api.nvim_create_autocmd("FileType", {
vim.schedule(function()
local status, result = pcall(api.nvim_win_set_cursor, 0, mark_pos)
if not status then
api.nvim_err_writeln(
string.format("Failed to resume cursor position. Context %s, error: %s", vim.inspect(ev), result)
)
api.nvim_err_writeln(string.format("Failed to resume cursor position. Context %s, error: %s",
vim.inspect(ev), result))
end
end)
-- the following two ways also seem to work,
@@ -205,18 +204,20 @@ api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
desc = "Define or overrride some highlight groups",
callback = function()
-- For yank highlight
vim.api.nvim_set_hl(0, "YankColor", { fg = "#34495E", bg = "#2ECC71", ctermfg = 59, ctermbg = 41 })
vim.cmd([[
" For yank highlight
highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
-- For cursor colors
vim.api.nvim_set_hl(0, "Cursor", { fg = "black", bg = "#00c918", bold = true })
vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
" For cursor colors
highlight Cursor cterm=bold gui=bold guibg=#00c918 guifg=black
highlight Cursor2 guifg=red guibg=red
-- For floating windows border highlight
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen" })
" For floating windows border highlight
highlight FloatBorder guifg=LightGreen guibg=NONE
-- highlight for matching parentheses
vim.api.nvim_set_hl(0, "MatchParen", { bold = true, underline = true })
" highlight for matching parentheses
highlight MatchParen cterm=bold,underline gui=bold,underline
]])
end,
})
@@ -225,14 +226,14 @@ api.nvim_create_autocmd("BufEnter", {
group = api.nvim_create_augroup("auto_close_win", { clear = true }),
desc = "Quit Nvim if we have only one window, and its filetype match our pattern",
callback = function(ev)
local quit_filetypes = { "qf", "vista", "NvimTree" }
local quit_filetypes = {'qf', 'vista', 'NvimTree'}
local should_quit = true
local tabwins = api.nvim_tabpage_list_wins(0)
for _, win in pairs(tabwins) do
local buf = api.nvim_win_get_buf(win)
local bf = fn.getbufvar(buf, "&filetype")
local bf = fn.getbufvar(buf, '&filetype')
if fn.index(quit_filetypes, bf) == -1 then
should_quit = false
@@ -242,14 +243,14 @@ api.nvim_create_autocmd("BufEnter", {
if should_quit then
vim.cmd("qall")
end
end,
end
})
api.nvim_create_autocmd({ "VimEnter", "DirChanged" }, {
api.nvim_create_autocmd({"VimEnter", "DirChanged"}, {
group = api.nvim_create_augroup("git_repo_check", { clear = true }),
pattern = "*",
desc = "check if we are inside Git repo",
command = "call utils#Inside_git_repo()",
command = "call utils#Inside_git_repo()"
})
-- ref: https://vi.stackexchange.com/a/169/15292
@@ -257,8 +258,8 @@ api.nvim_create_autocmd("BufReadPre", {
group = api.nvim_create_augroup("large_file", { clear = true }),
pattern = "*",
desc = "check if we are inside Git repo",
callback = function(ev)
local file_size_limit = 524288 -- 0.5MB
callback = function (ev)
local file_size_limit =524288 -- 0.5MB
local f = ev.file
if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
@@ -270,5 +271,5 @@ api.nvim_create_autocmd("BufReadPre", {
vim.bo.bufhidden = "unload"
vim.bo.undolevels = -1
end
end,
end
})

View File

@@ -1,28 +1,28 @@
local fn = vim.fn
local api = vim.api
local utils = require("utils")
local utils = require('utils')
------------------------------------------------------------------------
-- custom variables --
------------------------------------------------------------------------
vim.g.is_win = (utils.has("win32") or utils.has("win64")) and true or false
vim.g.is_linux = (utils.has("unix") and (not utils.has("macunix"))) and true or false
vim.g.is_mac = utils.has("macunix") and true or false
vim.g.is_mac = utils.has("macunix") and true or false
vim.g.logging_level = "info"
------------------------------------------------------------------------
-- builtin variables --
------------------------------------------------------------------------
vim.g.loaded_perl_provider = 0 -- Disable perl provider
vim.g.loaded_ruby_provider = 0 -- Disable ruby provider
vim.g.loaded_node_provider = 0 -- Disable node provider
vim.g.did_install_default_menus = 1 -- do not load menu
vim.g.loaded_perl_provider = 0 -- Disable perl provider
vim.g.loaded_ruby_provider = 0 -- Disable ruby provider
vim.g.loaded_node_provider = 0 -- Disable node provider
vim.g.did_install_default_menus = 1 -- do not load menu
if utils.executable("python3") then
if utils.executable('python3') then
if vim.g.is_win then
vim.g.python3_host_prog = fn.substitute(fn.exepath("python3"), ".exe$", "", "g")
vim.g.python3_host_prog = fn.substitute(fn.exepath("python3"), ".exe$", '', 'g')
else
vim.g.python3_host_prog = fn.exepath("python3")
end
@@ -32,18 +32,18 @@ else
end
-- Custom mapping <leader> (see `:h mapleader` for more info)
vim.g.mapleader = ","
vim.g.mapleader = ','
-- Enable highlighting for lua HERE doc inside vim script
vim.g.vimsyn_embed = "l"
vim.g.vimsyn_embed = 'l'
-- Use English as main language
vim.cmd([[language en_US.UTF-8]])
vim.cmd [[language en_US.UTF-8]]
-- Disable loading certain plugins
-- Whether to load netrw by default, see https://github.com/bling/dotvim/issues/4
vim.g.loaded_netrw = 1
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.netrw_liststyle = 3
if vim.g.is_win then

View File

@@ -357,6 +357,9 @@ local plugin_specs = {
end,
},
-- Better git commit experience
{ "rhysd/committia.vim", lazy = true },
{
"sindrets/diffview.nvim",
},
@@ -542,6 +545,7 @@ local plugin_specs = {
},
{
"CopilotC-Nvim/CopilotChat.nvim",
branch = "canary",
dependencies = {
{ "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
{ "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
@@ -569,25 +573,6 @@ local plugin_specs = {
end,
event = "VeryLazy",
},
{
-- show hint for code actions, the user can also implement code actions themselves,
-- see discussion here: https://github.com/neovim/neovim/issues/14869
"kosayoda/nvim-lightbulb",
config = function()
require("nvim-lightbulb").setup { autocmd = { enabled = true } }
end,
},
{
"Bekaboo/dropbar.nvim",
},
{
"vhyrro/luarocks.nvim",
priority = 1000, -- Very high priority is required, luarocks.nvim should run as the first plugin in your config.
opts = {
rocks = { "lua-toml" }, -- specifies a list of rocks to install
-- luarocks_build_args = { "--with-lua=/my/path" }, -- extra options to pass to luarocks's configuration script
},
},
}
require("lazy").setup {
@@ -599,6 +584,5 @@ require("lazy").setup {
},
rocks = {
enabled = false,
hererocks = false,
},
}

View File

@@ -1,58 +0,0 @@
-- Copy file path to clipboard
vim.api.nvim_create_user_command("CopyPath", function(context)
local full_path = vim.fn.glob("%:p")
local file_path = nil
if context["args"] == "nameonly" then
file_path = vim.fn.fnamemodify(full_path, ":t")
end
-- get the file path relative to project root
if context["args"] == "relative" then
local project_marker = { ".git", "pyproject.toml" }
local project_root = vim.fs.root(0, project_marker)
if project_root == nil then
vim.print("can not find project root")
return
end
file_path = vim.fn.substitute(full_path, project_root, "<project-root>", "g")
end
if context["args"] == "absolute" then
file_path = full_path
end
vim.fn.setreg("+", file_path)
vim.print("Filepath copied to clipboard!")
end, {
bang = false,
nargs = 1,
force = true,
desc = "Copy current file path to clipboard",
complete = function()
return { "nameonly", "relative", "absolute" }
end,
})
-- JSON format part of or the whole file
vim.api.nvim_create_user_command("JSONFormat", function(context)
local range = context["range"]
local line1 = context["line1"]
local line2 = context["line2"]
if range == 0 then
-- the command is invoked without range, then we assume whole buffer
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
vim.fn.execute(cmd_str)
elseif range == 2 then
-- the command is invoked with some range
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
vim.fn.execute(cmd_str)
else
vim.api.nvim_err_write(string.format("unsupported range: %s", range))
end
end, {
desc = "Format JSON string",
range = "%",
})

View File

@@ -45,3 +45,6 @@ function! s:md_to_pdf() abort
echoerr "Error running command"
endif
endfunction
" json format
command! -range JSONFormat <line1>,<line2>!python -m json.tool

View File

@@ -470,9 +470,3 @@ qpdf
Elasticsearch
kibana
submodule
unix
GCP
Kubernetes
pubsub
Luarocks
luarocks

View File

@@ -72,7 +72,7 @@ set wildmode=list:longest
set scrolloff=3
" Use mouse to select and resize windows, etc.
set mouse=
set mouse=nic " Enable mouse in several mode
set mousemodel=popup " Set the behaviour of mouse
set mousescroll=ver:1,hor:0
@@ -179,5 +179,3 @@ set diffopt+=linematch:60
set nowrap " do no wrap
set noruler
set showcmdloc=statusline

View File

@@ -79,7 +79,7 @@ let g:Lf_WorkingDirectoryMode = 'a'
nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR>
" Grep project files in popup window
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup --nameOnly<CR>
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
" Search vim help files
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>