feat(nvim): roll back to stable, vimwiki markdown
This commit is contained in:
parent
0e5b74e036
commit
c36ff90bd6
5 changed files with 51 additions and 179 deletions
|
@ -1,77 +1,47 @@
|
||||||
-- vim:fdm=marker
|
-- vim:fdm=marker
|
||||||
pcall(require, "impatient")
|
pcall(require, "impatient")
|
||||||
|
pcall(require, "plugins")
|
||||||
-- packer {{{
|
|
||||||
local fn = vim.fn
|
|
||||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
|
||||||
if fn.empty(fn.glob(install_path)) > 0 then
|
|
||||||
print("Cloning packer ..")
|
|
||||||
|
|
||||||
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
|
|
||||||
|
|
||||||
-- install plugins + compile their configs
|
|
||||||
vim.cmd("packadd packer.nvim")
|
|
||||||
require("plugins")
|
|
||||||
require("packer").sync()
|
|
||||||
end
|
|
||||||
|
|
||||||
require("utils")
|
|
||||||
pcall(require, "lsp")
|
pcall(require, "lsp")
|
||||||
|
|
||||||
-- custom packer command
|
-- true colors
|
||||||
local packer_cmd = function(callback)
|
vim.o.termguicolors = true
|
||||||
return function()
|
-- map leader to space
|
||||||
require("plugins")
|
|
||||||
require("packer")[callback]()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function cmd(lhs, fun, opt)
|
|
||||||
vim.api.nvim_create_user_command(lhs, fun, opt or {})
|
|
||||||
end
|
|
||||||
|
|
||||||
cmd("PackerClean", packer_cmd("clean"))
|
|
||||||
cmd("PackerCompile", packer_cmd("compile"))
|
|
||||||
cmd("PackerInstall", packer_cmd("install"))
|
|
||||||
cmd("PackerProfile", packer_cmd("profile"))
|
|
||||||
cmd("PackerStatus", packer_cmd("status"))
|
|
||||||
cmd("PackerSync", packer_cmd("sync"))
|
|
||||||
cmd("PackerUpdate", packer_cmd("update"))
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
-- prelude
|
|
||||||
vim.opt.laststatus = 3
|
|
||||||
vim.opt.list = true
|
|
||||||
vim.opt.number = true
|
|
||||||
vim.opt.relativenumber = true
|
|
||||||
vim.opt.scrolloff = 5
|
|
||||||
vim.opt.showtabline = 2
|
|
||||||
vim.opt.sidescrolloff = 15
|
|
||||||
vim.opt.splitbelow = true
|
|
||||||
vim.opt.splitright = true
|
|
||||||
vim.opt.termguicolors = true
|
|
||||||
vim.opt.shadafile = nil
|
|
||||||
|
|
||||||
-- basic boring stuff
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
vim.opt.mouse = "nv"
|
-- allow mouse in normal/visual mode
|
||||||
|
vim.o.mouse = "nv"
|
||||||
|
-- line numbers
|
||||||
|
vim.o.number = true
|
||||||
|
vim.o.relativenumber = true
|
||||||
|
vim.o.numberwidth = 5
|
||||||
|
-- scroll offsets
|
||||||
|
vim.o.scrolloff = 5
|
||||||
|
vim.o.sidescrolloff = 15
|
||||||
|
-- show leading/trailing whitespace
|
||||||
|
vim.o.list = true
|
||||||
|
-- always show status & tab line
|
||||||
|
vim.o.laststatus = 3
|
||||||
|
vim.o.showtabline = 2
|
||||||
|
-- completion height
|
||||||
|
vim.o.pumheight = 15
|
||||||
|
-- split directions
|
||||||
|
vim.o.splitbelow = true
|
||||||
|
vim.o.splitright = true
|
||||||
-- redefine word boundaries - '_' is a word seperator, this helps with snake_case
|
-- redefine word boundaries - '_' is a word seperator, this helps with snake_case
|
||||||
vim.cmd("set iskeyword-=_")
|
vim.opt.iskeyword:remove("_")
|
||||||
|
|
||||||
-- easier split navigation
|
-- easier split navigation
|
||||||
Nmap("<C-J>", "<C-W>j<CR>")
|
Nmap("<C-J>", "<C-W>j")
|
||||||
Nmap("<C-K>", "<C-W>k<CR>")
|
Nmap("<C-K>", "<C-W>k")
|
||||||
Nmap("<C-L>", "<C-W>l<CR>")
|
Nmap("<C-L>", "<C-W>l")
|
||||||
Nmap("<C-H>", "<C-W>h<CR>")
|
Nmap("<C-H>", "<C-W>h")
|
||||||
-- escape :terminal easier
|
-- escape :terminal easier
|
||||||
vim.cmd([[tnoremap <Esc> <C-\><C-n>]])
|
vim.cmd([[tnoremap <Esc> <C-\><C-n>]])
|
||||||
|
|
||||||
-- indentations settings
|
-- indentations settings
|
||||||
vim.opt.shiftwidth = 2
|
vim.o.shiftwidth = 2
|
||||||
vim.opt.tabstop = 2
|
vim.o.tabstop = 2
|
||||||
vim.opt.softtabstop = 2
|
vim.o.softtabstop = 2
|
||||||
vim.opt.expandtab = true
|
vim.o.expandtab = true
|
||||||
-- indentation autocmds for some filetypes
|
-- indentation autocmds for some filetypes
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
" smol spaces for soydev
|
" smol spaces for soydev
|
||||||
|
@ -80,30 +50,27 @@ autocmd FileType html,css,js,jsreact,ts,tsreact,json,yaml setlocal ts=2 sw=2 sts
|
||||||
autocmd FileType go,lua setlocal ts=4 sw=4 sts=4 noet
|
autocmd FileType go,lua setlocal ts=4 sw=4 sts=4 noet
|
||||||
" Spaces, based languages
|
" Spaces, based languages
|
||||||
autocmd FileType python,rust setlocal ts=4 sw=4 sts=4 et
|
autocmd FileType python,rust setlocal ts=4 sw=4 sts=4 et
|
||||||
|
autocmd FileType markdown let g:table_mode_corner='|'
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
-- auto-compile when lua files in `~/.config/nvim/*` change
|
||||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
pattern = "*.lua",
|
pattern = "*.lua",
|
||||||
callback = function()
|
callback = function()
|
||||||
|
local cfg_path = vim.fn.resolve(vim.fn.stdpath("config"))
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
if vim.fn.expand("%:p"):match(vim.fn.resolve(vim.fn.stdpath("config"))) then
|
if vim.fn.expand("%:p"):match(cfg_path) then
|
||||||
packer_cmd("compile")
|
vim.cmd("silent! PackerCompile")
|
||||||
end
|
end
|
||||||
end, 0)
|
end, 0)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- neovide settings {{{
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
vim.cmd("cd $HOME")
|
vim.cmd("cd $HOME")
|
||||||
vim.g.neovide_cursor_vfx_mode = "ripple"
|
vim.g.neovide_cursor_vfx_mode = "ripple"
|
||||||
vim.g.neovide_input_macos_alt_is_meta = true
|
vim.g.neovide_input_macos_alt_is_meta = true
|
||||||
vim.o.guifont = "VictorMono Nerd Font:h18"
|
vim.o.guifont = "VictorMono Nerd Font:h18"
|
||||||
-- allow copy & paste in neovide,
|
|
||||||
-- https://github.com/neovide/neovide/issues/1263
|
|
||||||
vim.cmd([[
|
|
||||||
map <D-v> "+p<CR>
|
|
||||||
map! <D-v> <C-R>+
|
|
||||||
tmap <D-v> <C-R>+
|
|
||||||
vmap <D-c> "+y<CR>
|
|
||||||
]])
|
|
||||||
end
|
end
|
||||||
|
-- }}}
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
-- use transparency in terminal only
|
-- use transparency in terminal only
|
||||||
local useTransparentBG = true
|
|
||||||
if vim.g.neovide then
|
|
||||||
useTransparentBG = false
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.g.catppuccin_flavour = "mocha"
|
vim.g.catppuccin_flavour = "mocha"
|
||||||
|
|
||||||
require("catppuccin").setup({
|
require("catppuccin").setup({
|
||||||
|
|
|
@ -1,40 +1,5 @@
|
||||||
local saga = require("lspsaga")
|
local saga = require("lspsaga")
|
||||||
saga.init_lsp_saga({
|
saga.init_lsp_saga()
|
||||||
symbol_in_winbar = {
|
|
||||||
in_custom = true,
|
|
||||||
enable = true,
|
|
||||||
separator = " > ",
|
|
||||||
show_file = true,
|
|
||||||
click_support = function(node, clicks, button, modifier)
|
|
||||||
-- To see all avaiable defails: vim.pretty_print(node)
|
|
||||||
local st = node.range.start
|
|
||||||
local en = node.range["end"]
|
|
||||||
if button == "l" then
|
|
||||||
if modifier == "c" then
|
|
||||||
print("lspsaga") -- ctrl left click to print "lspsaga"
|
|
||||||
end -- jump to node's ending line+char
|
|
||||||
if clicks == 2 then
|
|
||||||
-- double left click to visual select
|
|
||||||
vim.fn.cursor(st.line + 1, st.character + 1)
|
|
||||||
vim.cmd.normal("v")
|
|
||||||
vim.fn.cursor(en.line + 1, en.character + 1)
|
|
||||||
else -- jump to node's starting line+char
|
|
||||||
vim.fn.cursor(st.line + 1, st.character + 1)
|
|
||||||
end
|
|
||||||
elseif button == "r" then
|
|
||||||
if modifier == "c" then
|
|
||||||
print("lspsaga") -- shift right click to print "lspsaga"
|
|
||||||
end -- jump to node's ending line+char
|
|
||||||
vim.fn.cursor(en.line + 1, en.character + 1)
|
|
||||||
elseif button == "m" then
|
|
||||||
-- middle click to visual select node
|
|
||||||
vim.fn.cursor(st.line + 1, st.character + 1)
|
|
||||||
vim.cmd.normal("v")
|
|
||||||
vim.fn.cursor(en.line + 1, en.character + 1)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
Nmap("gr", "<cmd>Lspsaga rename<cr>")
|
Nmap("gr", "<cmd>Lspsaga rename<cr>")
|
||||||
Nmap("gx", "<cmd>Lspsaga code_action<cr>")
|
Nmap("gx", "<cmd>Lspsaga code_action<cr>")
|
||||||
|
@ -46,65 +11,6 @@ Nmap("gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>")
|
||||||
Nmap("<C-u>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1, '<c-u>')<cr>", {})
|
Nmap("<C-u>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1, '<c-u>')<cr>", {})
|
||||||
Nmap("<C-d>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1, '<c-d>')<cr>", {})
|
Nmap("<C-d>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1, '<c-d>')<cr>", {})
|
||||||
|
|
||||||
-- nullchilly winbar
|
|
||||||
local function get_file_name(include_path)
|
|
||||||
local file_name = require("lspsaga.symbolwinbar").get_file_name()
|
|
||||||
if vim.fn.bufname("%") == "" then
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
if include_path == false then
|
|
||||||
return file_name
|
|
||||||
end
|
|
||||||
-- Else if include path: ./lsp/saga.lua -> lsp > saga.lua
|
|
||||||
local sep = vim.loop.os_uname().sysname == "Windows" and "\\" or "/"
|
|
||||||
local path_list = vim.split(string.gsub(vim.fn.expand("%:~:.:h"), "%%", ""), sep)
|
|
||||||
local file_path = ""
|
|
||||||
for _, cur in ipairs(path_list) do
|
|
||||||
file_path = (cur == "." or cur == "~") and "" or file_path .. cur .. " " .. "%#LspSagaWinbarSep#>%*" .. " %*"
|
|
||||||
end
|
|
||||||
return file_path .. file_name
|
|
||||||
end
|
|
||||||
|
|
||||||
local function config_winbar()
|
|
||||||
local exclude = {
|
|
||||||
["teminal"] = true,
|
|
||||||
["toggleterm"] = true,
|
|
||||||
["prompt"] = true,
|
|
||||||
["NvimTree"] = true,
|
|
||||||
["help"] = true,
|
|
||||||
} -- Ignore float windows and exclude filetype
|
|
||||||
if vim.api.nvim_win_get_config(0).zindex or exclude[vim.bo.filetype] then
|
|
||||||
vim.wo.winbar = ""
|
|
||||||
else
|
|
||||||
local ok, lspsaga = pcall(require, "lspsaga.symbolwinbar")
|
|
||||||
local sym
|
|
||||||
if ok then
|
|
||||||
sym = lspsaga.get_symbol_node()
|
|
||||||
end
|
|
||||||
local win_val = ""
|
|
||||||
win_val = get_file_name(true) -- set to true to include path
|
|
||||||
if sym ~= nil then
|
|
||||||
win_val = win_val .. sym
|
|
||||||
end
|
|
||||||
vim.wo.winbar = win_val
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local events = { "BufEnter", "BufWinEnter", "CursorMoved" }
|
|
||||||
vim.api.nvim_create_autocmd(events, {
|
|
||||||
pattern = "*",
|
|
||||||
callback = function()
|
|
||||||
config_winbar()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("User", {
|
|
||||||
pattern = "LspsagaUpdateSymbol",
|
|
||||||
callback = function()
|
|
||||||
config_winbar()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
nnoremap <silent> <A-d> <cmd>lua require('lspsaga.floaterm').open_float_terminal()<CR>
|
nnoremap <silent> <A-d> <cmd>lua require('lspsaga.floaterm').open_float_terminal()<CR>
|
||||||
tnoremap <silent> <A-d> <C-\><C-n>:lua require('lspsaga.floaterm').close_float_terminal()<CR>
|
tnoremap <silent> <A-d> <C-\><C-n>:lua require('lspsaga.floaterm').close_float_terminal()<CR>
|
||||||
|
|
|
@ -63,10 +63,10 @@ local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protoco
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts)
|
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
|
||||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||||
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts)
|
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
-- after the language server attaches to the current buffer
|
-- after the language server attaches to the current buffer
|
||||||
|
@ -75,7 +75,7 @@ local on_attach = function(client, bufnr)
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
|
|
||||||
-- disable yaml diagnostics on Helm files
|
-- disable diagnostics on Helm files
|
||||||
if vim.bo[bufnr].buftype ~= "" or vim.bo[bufnr].filetype == "helm" then
|
if vim.bo[bufnr].buftype ~= "" or vim.bo[bufnr].filetype == "helm" then
|
||||||
vim.diagnostic.disable()
|
vim.diagnostic.disable()
|
||||||
end
|
end
|
||||||
|
@ -110,6 +110,7 @@ end
|
||||||
|
|
||||||
local common_config = {
|
local common_config = {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
}
|
}
|
||||||
|
|
||||||
local lsp = require("lspconfig")
|
local lsp = require("lspconfig")
|
||||||
|
|
|
@ -20,14 +20,12 @@ return packer.startup(function(use)
|
||||||
use({
|
use({
|
||||||
"catppuccin/nvim",
|
"catppuccin/nvim",
|
||||||
as = "catppuccin",
|
as = "catppuccin",
|
||||||
branch = "dev",
|
|
||||||
config = function()
|
config = function()
|
||||||
require("config/catppuccin")
|
require("config/catppuccin")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
use({
|
use({
|
||||||
"Pocco81/true-zen.nvim",
|
"Pocco81/true-zen.nvim",
|
||||||
branch = "main",
|
|
||||||
config = function()
|
config = function()
|
||||||
require("true-zen").setup({
|
require("true-zen").setup({
|
||||||
modes = {
|
modes = {
|
||||||
|
@ -418,10 +416,15 @@ return packer.startup(function(use)
|
||||||
vim.g.vimwiki_list = {
|
vim.g.vimwiki_list = {
|
||||||
{
|
{
|
||||||
auto_export = 1,
|
auto_export = 1,
|
||||||
path_html = "~/.local/share/vimwiki/",
|
|
||||||
path = "~/.local/share/vimwiki/",
|
path = "~/.local/share/vimwiki/",
|
||||||
syntax = "markdown",
|
syntax = "markdown",
|
||||||
ext = ".md",
|
ext = ".md",
|
||||||
|
path_html = "~/vimwiki/",
|
||||||
|
template_path = "~/.config/vimwiki/templates/",
|
||||||
|
template_default = "default",
|
||||||
|
template_ext = ".tpl",
|
||||||
|
custom_wiki2html = "vimwiki_markdown",
|
||||||
|
html_filename_parameterization = 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
@ -456,7 +459,7 @@ return packer.startup(function(use)
|
||||||
local auto_dark_mode = require("auto-dark-mode")
|
local auto_dark_mode = require("auto-dark-mode")
|
||||||
auto_dark_mode.setup({
|
auto_dark_mode.setup({
|
||||||
---@diagnostic disable-next-line: assign-type-mismatch
|
---@diagnostic disable-next-line: assign-type-mismatch
|
||||||
update_interval = 5000,
|
update_interval = 1000,
|
||||||
set_dark_mode = function()
|
set_dark_mode = function()
|
||||||
vim.cmd("Catppuccin mocha")
|
vim.cmd("Catppuccin mocha")
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in a new issue