mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
13 Commits
v0.8.0
...
6c1dbdf8fc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c1dbdf8fc | ||
|
|
202a9a088d | ||
|
|
d939cc75c6 | ||
|
|
26921309ec | ||
|
|
a6f716558b | ||
|
|
3539207913 | ||
|
|
d8b92965e8 | ||
|
|
ebf7170916 | ||
|
|
696466469b | ||
|
|
7a5be43600 | ||
|
|
3b39067097 | ||
|
|
e6b3be0777 | ||
|
|
acb423984a |
@@ -1,10 +1,5 @@
|
|||||||
set commentstring=//\ %s
|
set commentstring=//\ %s
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
" Disable inserting comment leader after hitting o or O or <Enter>
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
set formatoptions-=o
|
set formatoptions-=o
|
||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
" Disable inserting comment leader after hitting o or O or <Enter>
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
set formatoptions-=o
|
set formatoptions-=o
|
||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
set formatoptions-=o
|
set formatoptions-=o
|
||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
nnoremap <silent> <F9> :luafile %<CR>
|
nnoremap <silent> <F9> :luafile %<CR>
|
||||||
|
|
||||||
" For delimitMate
|
" For delimitMate
|
||||||
|
|||||||
@@ -8,5 +8,10 @@ set sidescroll=5
|
|||||||
set sidescrolloff=2
|
set sidescrolloff=2
|
||||||
set colorcolumn=100
|
set colorcolumn=100
|
||||||
|
|
||||||
|
set tabstop=4 " number of visual spaces per TAB
|
||||||
|
set softtabstop=4 " number of spaces in tab when editing
|
||||||
|
set shiftwidth=4 " number of spaces to use for autoindent
|
||||||
|
set expandtab " expand tab to spaces so that tabs are spaces
|
||||||
|
|
||||||
" For delimitMate
|
" For delimitMate
|
||||||
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|||||||
@@ -12,9 +12,4 @@ set foldmethod=expr foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
|
|||||||
" see `:h K` and https://stackoverflow.com/q/15867323/6064933
|
" see `:h K` and https://stackoverflow.com/q/15867323/6064933
|
||||||
set keywordprg=:help
|
set keywordprg=:help
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
nnoremap <silent> <F9> :source %<CR>
|
nnoremap <silent> <F9> :source %<CR>
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
" Turn off syntax highlighting for large YAML files.
|
" Turn off syntax highlighting for large YAML files.
|
||||||
if line('$') > 500
|
if line('$') > 500
|
||||||
setlocal syntax=OFF
|
setlocal syntax=OFF
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ vim.g.mapleader = ','
|
|||||||
vim.g.vimsyn_embed = 'l'
|
vim.g.vimsyn_embed = 'l'
|
||||||
|
|
||||||
-- Use English as main language
|
-- Use English as main language
|
||||||
if not vim.g.is_mac then
|
vim.cmd [[language en_US.UTF-8]]
|
||||||
vim.cmd [[language en_US.utf-8]]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Disable loading certain plugins
|
-- Disable loading certain plugins
|
||||||
|
|
||||||
|
|||||||
@@ -85,16 +85,15 @@ keymap.set("n", "<leader>ev", "<cmd>tabnew $MYVIMRC <bar> tcd %:h<cr>", {
|
|||||||
desc = "open init.lua",
|
desc = "open init.lua",
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set("n", "<leader>sv", "", {
|
keymap.set("n", "<leader>sv", function()
|
||||||
silent = true,
|
|
||||||
desc = "reload init.lua",
|
|
||||||
callback = function()
|
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
update $MYVIMRC
|
update $MYVIMRC
|
||||||
source $MYVIMRC
|
source $MYVIMRC
|
||||||
]])
|
]])
|
||||||
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
|
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
|
||||||
end,
|
end, {
|
||||||
|
silent = true,
|
||||||
|
desc = "reload init.lua",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
|
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
|
||||||
@@ -173,25 +172,23 @@ keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL tex
|
|||||||
keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
|
keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
|
||||||
|
|
||||||
-- Do not move my cursor when joining lines.
|
-- Do not move my cursor when joining lines.
|
||||||
keymap.set("n", "J", "", {
|
keymap.set("n", "J", function()
|
||||||
desc = "join line",
|
|
||||||
callback = function()
|
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
normal! mzJ`z
|
normal! mzJ`z
|
||||||
delmarks z
|
delmarks z
|
||||||
]])
|
]])
|
||||||
end,
|
end, {
|
||||||
|
desc = "join line",
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set("n", "gJ", "mzgJ`z", {
|
keymap.set("n", "gJ", function()
|
||||||
desc = "join visual lines",
|
|
||||||
callback = function()
|
|
||||||
-- we must use `normal!`, otherwise it will trigger recursive mapping
|
-- we must use `normal!`, otherwise it will trigger recursive mapping
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
normal! zmgJ`z
|
normal! zmgJ`z
|
||||||
delmarks z
|
delmarks z
|
||||||
]])
|
]])
|
||||||
end,
|
end, {
|
||||||
|
desc = "join visual lines",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Break inserted text into smaller undo units when we insert some punctuation chars.
|
-- Break inserted text into smaller undo units when we insert some punctuation chars.
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ set backup " create backup for files
|
|||||||
set backupcopy=yes " copy the original file to backupdir and overwrite it
|
set backupcopy=yes " copy the original file to backupdir and overwrite it
|
||||||
|
|
||||||
" General tab settings
|
" General tab settings
|
||||||
set tabstop=4 " number of visual spaces per TAB
|
set tabstop=2 " number of visual spaces per TAB
|
||||||
set softtabstop=4 " number of spaces in tab when editing
|
set softtabstop=2 " number of spaces in tab when editing
|
||||||
set shiftwidth=4 " number of spaces to use for autoindent
|
set shiftwidth=2 " number of spaces to use for autoindent
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
set expandtab " expand tab to spaces so that tabs are spaces
|
||||||
|
|
||||||
" Set matching pairs of characters and highlight matching brackets
|
" Set matching pairs of characters and highlight matching brackets
|
||||||
@@ -75,6 +75,7 @@ set scrolloff=3
|
|||||||
" Use mouse to select and resize windows, etc.
|
" Use mouse to select and resize windows, etc.
|
||||||
set mouse=nic " Enable mouse in several mode
|
set mouse=nic " Enable mouse in several mode
|
||||||
set mousemodel=popup " Set the behaviour of mouse
|
set mousemodel=popup " Set the behaviour of mouse
|
||||||
|
set mousescroll=ver:1,hor:6
|
||||||
|
|
||||||
" Disable showing current mode on command line since statusline plugins can show it.
|
" Disable showing current mode on command line since statusline plugins can show it.
|
||||||
set noshowmode
|
set noshowmode
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
local api = vim.api
|
||||||
|
local keymap = vim.keymap
|
||||||
local dashboard = require("dashboard")
|
local dashboard = require("dashboard")
|
||||||
|
|
||||||
dashboard.custom_header = {
|
dashboard.custom_header = {
|
||||||
@@ -56,10 +58,11 @@ dashboard.custom_center = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.cmd([[
|
api.nvim_create_autocmd("FileType", {
|
||||||
augroup dashboard_enter
|
pattern = "dashboard",
|
||||||
au!
|
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
|
||||||
autocmd FileType dashboard nnoremap <buffer> q :qa<CR>
|
callback = function ()
|
||||||
autocmd FileType dashboard nnoremap <buffer> e :enew<CR>
|
keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true })
|
||||||
augroup END
|
keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true })
|
||||||
]])
|
end
|
||||||
|
})
|
||||||
|
|||||||
@@ -34,5 +34,15 @@ keymap.set("n", "N", "", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set("n", "*", "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>")
|
keymap.set("n", "*", "", {
|
||||||
keymap.set("n", "#", "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>")
|
callback = function()
|
||||||
|
vim.fn.execute("normal! *N")
|
||||||
|
hlslens.start()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
keymap.set("n", "#", "", {
|
||||||
|
callback = function()
|
||||||
|
vim.fn.execute("normal! #N")
|
||||||
|
hlslens.start()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|||||||
@@ -69,12 +69,24 @@ local custom_attach = function(client, bufnr)
|
|||||||
hi! link LspReferenceRead Visual
|
hi! link LspReferenceRead Visual
|
||||||
hi! link LspReferenceText Visual
|
hi! link LspReferenceText Visual
|
||||||
hi! link LspReferenceWrite Visual
|
hi! link LspReferenceWrite Visual
|
||||||
augroup lsp_document_highlight
|
|
||||||
autocmd! * <buffer>
|
|
||||||
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
|
||||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
|
||||||
augroup END
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||||
|
api.nvim_create_autocmd("CursorHold" , {
|
||||||
|
group = gid,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function ()
|
||||||
|
lsp.buf.document_highlight()
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("CursorMoved" , {
|
||||||
|
group = gid,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function ()
|
||||||
|
lsp.buf.clear_references()
|
||||||
|
end
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.g.logging_level == "debug" then
|
if vim.g.logging_level == "debug" then
|
||||||
@@ -83,9 +95,7 @@ local custom_attach = function(client, bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = lsp.protocol.make_client_capabilities()
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
|
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
|
|||||||
@@ -4,24 +4,31 @@ local fn = vim.fn
|
|||||||
-- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory.
|
-- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory.
|
||||||
vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer"
|
vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer"
|
||||||
|
|
||||||
|
--- Install packer if it has not been installed.
|
||||||
|
--- Return:
|
||||||
|
--- true: if this is a fresh install of packer
|
||||||
|
--- false: if packer has been installed
|
||||||
|
local function packer_ensure_install()
|
||||||
-- Where to install packer.nvim -- the package manager (we make it opt)
|
-- Where to install packer.nvim -- the package manager (we make it opt)
|
||||||
local packer_dir = vim.g.plugin_home .. "/opt/packer.nvim"
|
local packer_dir = vim.g.plugin_home .. "/opt/packer.nvim"
|
||||||
|
|
||||||
-- Whether this is a fresh install, i.e., packer itself and plugins have not been installed.
|
if fn.glob(packer_dir) ~= "" then
|
||||||
local fresh_install = false
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Auto-install packer in case it hasn't been installed.
|
-- Auto-install packer in case it hasn't been installed.
|
||||||
if fn.glob(packer_dir) == "" then
|
vim.api.nvim_echo({ { "Installing packer.nvim", "Type" } }, true, {})
|
||||||
fresh_install = true
|
|
||||||
|
|
||||||
-- Now we need to install packer.nvim first.
|
|
||||||
local packer_repo = "https://github.com/wbthomason/packer.nvim"
|
local packer_repo = "https://github.com/wbthomason/packer.nvim"
|
||||||
local install_cmd = string.format("!git clone --depth=1 %s %s", packer_repo, packer_dir)
|
local install_cmd = string.format("!git clone --depth=1 %s %s", packer_repo, packer_dir)
|
||||||
|
|
||||||
vim.api.nvim_echo({ { "Installing packer.nvim", "Type" } }, true, {})
|
|
||||||
vim.cmd(install_cmd)
|
vim.cmd(install_cmd)
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local fresh_install = packer_ensure_install()
|
||||||
|
|
||||||
-- Load packer.nvim
|
-- Load packer.nvim
|
||||||
vim.cmd("packadd packer.nvim")
|
vim.cmd("packadd packer.nvim")
|
||||||
|
|
||||||
@@ -99,9 +106,6 @@ packer.startup {
|
|||||||
config = [[require('config.hlslens')]],
|
config = [[require('config.hlslens')]],
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Stay after pressing * and search selected text
|
|
||||||
use { "haya14busa/vim-asterisk", event = "VimEnter" }
|
|
||||||
|
|
||||||
-- File search, tag search and more
|
-- File search, tag search and more
|
||||||
if vim.g.is_win then
|
if vim.g.is_win then
|
||||||
use { "Yggdroot/LeaderF", cmd = "Leaderf" }
|
use { "Yggdroot/LeaderF", cmd = "Leaderf" }
|
||||||
@@ -255,9 +259,6 @@ packer.startup {
|
|||||||
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
|
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
|
||||||
use { "godlygeek/tabular", cmd = { "Tabularize" } }
|
use { "godlygeek/tabular", cmd = { "Tabularize" } }
|
||||||
|
|
||||||
-- Markdown JSON header highlight plugin
|
|
||||||
use { "elzr/vim-json", ft = { "json", "markdown" } }
|
|
||||||
|
|
||||||
-- Markdown previewing (only for Mac and Windows)
|
-- Markdown previewing (only for Mac and Windows)
|
||||||
if vim.g.is_win or vim.g.is_mac then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
use {
|
use {
|
||||||
|
|||||||
@@ -440,3 +440,15 @@ Postgres
|
|||||||
plpgsql
|
plpgsql
|
||||||
postgres
|
postgres
|
||||||
PySpark
|
PySpark
|
||||||
|
winbar
|
||||||
|
cmdline
|
||||||
|
shada
|
||||||
|
async
|
||||||
|
localhost
|
||||||
|
JetBrains
|
||||||
|
localhost
|
||||||
|
MariaDB
|
||||||
|
SQLite
|
||||||
|
Pgadmin
|
||||||
|
Datagrip
|
||||||
|
mysql
|
||||||
|
|||||||
Reference in New Issue
Block a user