mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
14 Commits
plug/leap-
...
v0.9.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a6379ca5d | ||
|
|
855a88b532 | ||
|
|
892cd49f06 | ||
|
|
e53ee104ec | ||
|
|
671c78df9b | ||
|
|
1608a36dd3 | ||
|
|
450f058da5 | ||
|
|
e2f348cb37 | ||
|
|
fc8175d32d | ||
|
|
4034b6b673 | ||
|
|
67a4b6e6d0 | ||
|
|
bb27d93433 | ||
|
|
9d9c3ef32f | ||
|
|
00e8c77b23 |
@@ -42,7 +42,7 @@ let g:Lf_UseMemoryCache = 0
|
|||||||
|
|
||||||
" Ignore certain files and directories when searching files
|
" Ignore certain files and directories when searching files
|
||||||
let g:Lf_WildIgnore = {
|
let g:Lf_WildIgnore = {
|
||||||
\ 'dir': ['.git', '__pycache__', '.DS_Store'],
|
\ 'dir': ['.git', '__pycache__', '.DS_Store', '*_cache'],
|
||||||
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
|
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
|
||||||
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
|
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
|
||||||
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
|
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
|
||||||
@@ -109,6 +109,20 @@ let g:Lf_PopupColorscheme = 'gruvbox_material'
|
|||||||
" items.
|
" items.
|
||||||
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
|
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
|
||||||
|
|
||||||
|
" do not preview results, it will add the file to buffer list
|
||||||
|
let g:Lf_PreviewResult = {
|
||||||
|
\ 'File': 0,
|
||||||
|
\ 'Buffer': 0,
|
||||||
|
\ 'Mru': 0,
|
||||||
|
\ 'Tag': 0,
|
||||||
|
\ 'BufTag': 1,
|
||||||
|
\ 'Function': 1,
|
||||||
|
\ 'Line': 0,
|
||||||
|
\ 'Colorscheme': 0,
|
||||||
|
\ 'Rg': 0,
|
||||||
|
\ 'Gtags': 0
|
||||||
|
\}
|
||||||
|
|
||||||
""""""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
|
""""""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
|
||||||
if g:is_win || g:is_mac
|
if g:is_win || g:is_mac
|
||||||
" Disable netrw's gx mapping.
|
" Disable netrw's gx mapping.
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ pip install -U pynvim
|
|||||||
[python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc.
|
[python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc.
|
||||||
|
|
||||||
```
|
```
|
||||||
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
|
pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort python-lsp-black
|
||||||
```
|
```
|
||||||
|
|
||||||
Note the executable for pylsp is also named `pylsp`. You need to set its PATH correctly.
|
Note the executable for pylsp is also named `pylsp`. You need to set its PATH correctly.
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ fi
|
|||||||
|
|
||||||
# Install some Python packages used by Nvim plugins.
|
# Install some Python packages used by Nvim plugins.
|
||||||
echo "Installing Python packages"
|
echo "Installing Python packages"
|
||||||
declare -a PY_PACKAGES=("pynvim" 'python-lsp-server[all]' "black" "vim-vint" "pyls-isort" "pylsp-mypy")
|
declare -a PY_PACKAGES=("pynvim" 'python-lsp-server[all]' "vim-vint" "python-lsp-isort" "pylsp-mypy" "python-lsp-black")
|
||||||
|
|
||||||
if [[ "$SYSTEM_PYTHON" = true ]]; then
|
if [[ "$SYSTEM_PYTHON" = true ]]; then
|
||||||
echo "Using system Python to install $(PY_PACKAGES)"
|
echo "Using system Python to install $(PY_PACKAGES)"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ scoop install miniconda3
|
|||||||
pip install -U pynvim
|
pip install -U pynvim
|
||||||
|
|
||||||
# Install python-language-server
|
# Install python-language-server
|
||||||
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
|
pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort
|
||||||
|
|
||||||
# Install visual c++ redistribution
|
# Install visual c++ redistribution
|
||||||
scoop install vcredist2022
|
scoop install vcredist2022
|
||||||
|
|||||||
10
init.lua
10
init.lua
@@ -36,8 +36,14 @@ local core_conf_files = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- source all the core config files
|
-- source all the core config files
|
||||||
for _, name in ipairs(core_conf_files) do
|
for _, file_name in ipairs(core_conf_files) do
|
||||||
local path = string.format("%s/core/%s", vim.fn.stdpath("config"), name)
|
if vim.endswith(file_name, 'vim') then
|
||||||
|
local path = string.format("%s/core/%s", vim.fn.stdpath("config"), file_name)
|
||||||
local source_cmd = "source " .. path
|
local source_cmd = "source " .. path
|
||||||
vim.cmd(source_cmd)
|
vim.cmd(source_cmd)
|
||||||
|
else
|
||||||
|
local module_name, _ = string.gsub(file_name, "%.lua", "")
|
||||||
|
package.loaded[module_name] = nil
|
||||||
|
require(module_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ require("bufferline").setup {
|
|||||||
icon = "▎", -- this should be omitted if indicator style is not 'icon'
|
icon = "▎", -- this should be omitted if indicator style is not 'icon'
|
||||||
style = "icon",
|
style = "icon",
|
||||||
},
|
},
|
||||||
buffer_close_icon = "",
|
buffer_close_icon = "",
|
||||||
modified_icon = "●",
|
modified_icon = "●",
|
||||||
close_icon = "",
|
close_icon = "",
|
||||||
left_trunc_marker = "",
|
left_trunc_marker = "",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ local api = vim.api
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local dashboard = require("dashboard")
|
local dashboard = require("dashboard")
|
||||||
|
|
||||||
conf = {}
|
local conf = {}
|
||||||
conf.header = {
|
conf.header = {
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
@@ -21,25 +21,25 @@ conf.header = {
|
|||||||
|
|
||||||
conf.center = {
|
conf.center = {
|
||||||
{
|
{
|
||||||
icon = " ",
|
icon = " ",
|
||||||
desc = "Find File ",
|
desc = "Find File ",
|
||||||
action = "Leaderf file --popup",
|
action = "Leaderf file --popup",
|
||||||
key = "<Leader> f f",
|
key = "<Leader> f f",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon = " ",
|
icon = " ",
|
||||||
desc = "Recently opened files ",
|
desc = "Recently opened files ",
|
||||||
action = "Leaderf mru --popup",
|
action = "Leaderf mru --popup",
|
||||||
key = "<Leader> f r",
|
key = "<Leader> f r",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon = " ",
|
icon = " ",
|
||||||
desc = "Project grep ",
|
desc = "Project grep ",
|
||||||
action = "Leaderf rg --popup",
|
action = "Leaderf rg --popup",
|
||||||
key = "<Leader> f g",
|
key = "<Leader> f g",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon = " ",
|
icon = " ",
|
||||||
desc = "Open Nvim config ",
|
desc = "Open Nvim config ",
|
||||||
action = "tabnew $MYVIMRC | tcd %:p:h",
|
action = "tabnew $MYVIMRC | tcd %:p:h",
|
||||||
key = "<Leader> e v",
|
key = "<Leader> e v",
|
||||||
@@ -51,7 +51,7 @@ conf.center = {
|
|||||||
key = "e",
|
key = "e",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon = " ",
|
icon = " ",
|
||||||
desc = "Quit Nvim ",
|
desc = "Quit Nvim ",
|
||||||
-- desc = "Quit Nvim ",
|
-- desc = "Quit Nvim ",
|
||||||
action = "qa",
|
action = "qa",
|
||||||
|
|||||||
@@ -2,24 +2,36 @@ local keymap = vim.keymap
|
|||||||
local gitlinker = require("gitlinker")
|
local gitlinker = require("gitlinker")
|
||||||
|
|
||||||
gitlinker.setup {
|
gitlinker.setup {
|
||||||
|
callbacks = {
|
||||||
|
["dev.azure.com"] = function(url_data)
|
||||||
|
vim.print(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"
|
||||||
|
end
|
||||||
|
return url
|
||||||
|
end
|
||||||
|
},
|
||||||
mappings = nil,
|
mappings = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
keymap.set({ "n", "v" }, "<leader>gl", "", {
|
keymap.set({ "n", "v" }, "<leader>gl", function()
|
||||||
silent = true,
|
|
||||||
desc = "get git permlink",
|
|
||||||
callback = function()
|
|
||||||
local mode = string.lower(vim.fn.mode())
|
local mode = string.lower(vim.fn.mode())
|
||||||
gitlinker.get_buf_range_url(mode)
|
gitlinker.get_buf_range_url(mode)
|
||||||
end,
|
end, {
|
||||||
|
silent = true,
|
||||||
|
desc = "get git permlink",
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set("n", "<leader>gb", "", {
|
keymap.set("n", "<leader>gb", function()
|
||||||
silent = true,
|
|
||||||
desc = "browse repo in browser",
|
|
||||||
callback = function()
|
|
||||||
gitlinker.get_repo_url({
|
gitlinker.get_repo_url({
|
||||||
action_callback = gitlinker.actions.open_in_browser
|
action_callback = gitlinker.actions.open_in_browser
|
||||||
})
|
})
|
||||||
end
|
end, {
|
||||||
|
silent = true,
|
||||||
|
desc = "browse repo in browser",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ local diagnostic = vim.diagnostic
|
|||||||
|
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
|
||||||
|
-- set quickfix list from diagnostics in a certain buffer, not the whole workspace
|
||||||
|
local set_qflist = function(buf_num, severity)
|
||||||
|
local diagnostics = nil
|
||||||
|
diagnostics = diagnostic.get(buf_num, { severity = severity })
|
||||||
|
|
||||||
|
local qf_items = diagnostic.toqflist(diagnostics)
|
||||||
|
vim.fn.setqflist({}, ' ', { title = 'Diagnostics', items = qf_items })
|
||||||
|
|
||||||
|
-- open quickfix by default
|
||||||
|
vim.cmd[[copen]]
|
||||||
|
end
|
||||||
|
|
||||||
local custom_attach = function(client, bufnr)
|
local custom_attach = function(client, bufnr)
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
local map = function(mode, l, r, opts)
|
local map = function(mode, l, r, opts)
|
||||||
@@ -23,7 +35,10 @@ local custom_attach = function(client, bufnr)
|
|||||||
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
|
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
|
||||||
map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" })
|
map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" })
|
||||||
map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" })
|
map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" })
|
||||||
map("n", "<space>q", diagnostic.setqflist, { desc = "put diagnostic to qf" })
|
-- 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>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
|
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>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" })
|
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
|
||||||
@@ -99,17 +114,40 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
if utils.executable("pylsp") then
|
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.pylsp.setup {
|
lspconfig.pylsp.setup {
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
settings = {
|
settings = {
|
||||||
pylsp = {
|
pylsp = {
|
||||||
plugins = {
|
plugins = {
|
||||||
|
-- formatter options
|
||||||
|
black = { enabled = true },
|
||||||
|
autopep8 = { enabled = false },
|
||||||
|
yapf = { enabled = false },
|
||||||
|
-- linter options
|
||||||
pylint = { enabled = true, executable = "pylint" },
|
pylint = { enabled = true, executable = "pylint" },
|
||||||
|
ruff = { enabled = false },
|
||||||
pyflakes = { enabled = false },
|
pyflakes = { enabled = false },
|
||||||
pycodestyle = { 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 },
|
jedi_completion = { fuzzy = true },
|
||||||
pyls_isort = { enabled = true },
|
-- import sorting
|
||||||
pylsp_mypy = { enabled = true },
|
isort = { enabled = true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -209,10 +247,10 @@ if utils.executable("lua-language-server") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Change diagnostic signs.
|
-- Change diagnostic signs.
|
||||||
fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" })
|
fn.sign_define("DiagnosticSignError", { text = '🆇', texthl = "DiagnosticSignError" })
|
||||||
fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
|
fn.sign_define("DiagnosticSignWarn", { text = '⚠️', texthl = "DiagnosticSignWarn" })
|
||||||
fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
|
fn.sign_define("DiagnosticSignInfo", { text = 'ℹ️', texthl = "DiagnosticSignInfo" })
|
||||||
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
fn.sign_define("DiagnosticSignHint", { text = '', texthl = "DiagnosticSignHint" })
|
||||||
|
|
||||||
-- global config for diagnostic
|
-- global config for diagnostic
|
||||||
diagnostic.config {
|
diagnostic.config {
|
||||||
|
|||||||
@@ -127,6 +127,11 @@ require("lualine").setup {
|
|||||||
spell,
|
spell,
|
||||||
color = { fg = "black", bg = "#a7c080" },
|
color = { fg = "black", bg = "#a7c080" },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"diagnostics",
|
||||||
|
sources = { "nvim_diagnostic" },
|
||||||
|
symbols = {error = '🆇 ', warn = '⚠️ ', info = 'ℹ️ ', hint = ' '},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
"encoding",
|
"encoding",
|
||||||
@@ -140,13 +145,11 @@ require("lualine").setup {
|
|||||||
},
|
},
|
||||||
"filetype",
|
"filetype",
|
||||||
},
|
},
|
||||||
lualine_y = { "progress" },
|
lualine_y = {
|
||||||
lualine_z = {
|
|
||||||
"location",
|
"location",
|
||||||
{
|
"progress",
|
||||||
"diagnostics",
|
|
||||||
sources = { "nvim_diagnostic" },
|
|
||||||
},
|
},
|
||||||
|
lualine_z = {
|
||||||
{
|
{
|
||||||
trailing_space,
|
trailing_space,
|
||||||
color = "WarningMsg",
|
color = "WarningMsg",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
require("nvim-treesitter.configs").setup {
|
require("nvim-treesitter.configs").setup {
|
||||||
ensure_installed = { "python", "cpp", "lua", "vim", "json" },
|
ensure_installed = { "python", "cpp", "lua", "vim", "json", "toml" },
|
||||||
ignore_install = {}, -- List of parsers to ignore installing
|
ignore_install = {}, -- List of parsers to ignore installing
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true, -- false will disable the whole extension
|
enable = true, -- false will disable the whole extension
|
||||||
|
|||||||
Reference in New Issue
Block a user