adding back vimwiki for lua as well as transparency support, minor tweaks
This commit is contained in:
parent
7c5b9396cc
commit
4ecb1486bf
@ -3,6 +3,8 @@
|
||||
-- Find the original file and additional credits at: https://github.com/w0ng/vim-hybrid
|
||||
--
|
||||
-- ]]
|
||||
-- TODO
|
||||
--
|
||||
|
||||
local M = {}
|
||||
|
||||
@ -80,6 +82,7 @@ M.setup = function()
|
||||
hi("Visual", { bg = colors.selection.gui, ctermbg = colors.selection.cterm })
|
||||
hi("Search", { fg = colors.background.gui, bg = colors.yellow.gui, ctermfg = colors.background.cterm, ctermbg = colors.yellow.cterm })
|
||||
hi("Title", { fg = colors.yellow.gui, ctermfg = colors.yellow.cterm })
|
||||
hi("Todo", { fg = colors.add_fg.gui, ctermfg = colors.add_fg.cterm })
|
||||
|
||||
-- Messages
|
||||
hi("ModeMsg", { fg = colors.green.gui, ctermfg = colors.green.cterm })
|
||||
|
||||
@ -3,18 +3,23 @@ vim.g.mapleader = " "
|
||||
-- disable vim copying via windows cmd for system takeover
|
||||
-- vim.keymap.set({"n","v","i"},"<C-c>",'<Nop>', { noremap = true })
|
||||
|
||||
Transparent = false
|
||||
-- allows for toggling of background
|
||||
local function ToggleTransparent()
|
||||
Transparent = not Transparent
|
||||
if Transparent then
|
||||
vim.cmd("hi Normal ctermbg=NONE")
|
||||
vim.cmd("hi Normal ctermbg=NONE guibg=NONE")
|
||||
else
|
||||
-- 234 is hybrid dark bg color
|
||||
vim.cmd("hi Normal ctermbg=234")
|
||||
vim.cmd("hi Normal ctermbg=234 guibg='#1d1f21'")
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>b", ":lua ToggleTransparent()<CR>")
|
||||
vim.keymap.set("n", "<leader>b", ToggleTransparent)
|
||||
|
||||
if os.getenv("WAYLAND_DISPLAY") then
|
||||
ToggleTransparent()
|
||||
end
|
||||
|
||||
-- simple spell check toggle
|
||||
local function SpellToggle()
|
||||
@ -25,7 +30,7 @@ local function SpellToggle()
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>a", ":lua SpellToggle()<CR>")
|
||||
vim.keymap.set("n", "<leader>a", SpellToggle)
|
||||
|
||||
-- markdown preview
|
||||
vim.keymap.set("n", "<leader>p", ":MarkdownPreviewToggle<CR>")
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- prevent cursor override
|
||||
vim.cmd('set guicursor=')
|
||||
-- vim.cmd('set guicursor=')
|
||||
vim.opt.guicursor = ""
|
||||
vim.cmd('let g:do_filetype_lua=1')
|
||||
|
||||
-- basic settings
|
||||
@ -20,9 +21,6 @@ vim.opt.compatible = false
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.hlsearch = true
|
||||
|
||||
-- defaults to transparent
|
||||
Transparent = true
|
||||
|
||||
-- timeouts
|
||||
vim.opt.ttimeout = true
|
||||
vim.opt.ttimeoutlen = 100
|
||||
@ -93,3 +91,14 @@ vim.opt.conceallevel = 2
|
||||
vim.g.vim_markdown_folding_disabled = 1
|
||||
vim.g.vim_markdown_math = 1
|
||||
vim.g.vim_markdown_strikethrough = 1
|
||||
|
||||
-- custom TODO highlighting
|
||||
-- vim.cmd("syntax on")
|
||||
vim.cmd("highlight default link MyTodo Todo")
|
||||
-- vim.cmd([[silent! syntax clear MyTodo]])
|
||||
--
|
||||
-- -- Tag keywords anywhere (including comments/strings)
|
||||
-- vim.cmd([[
|
||||
-- syntax match MyTodo /\v<(TODO|FIXME|NOTE|HACK|BUG)>/ containedin=ALL
|
||||
-- highlight default link MyTodo Todo
|
||||
-- ]])
|
||||
|
||||
79
lua/nvimwiki.lua
Normal file
79
lua/nvimwiki.lua
Normal file
@ -0,0 +1,79 @@
|
||||
local M = {}
|
||||
|
||||
M.config = {
|
||||
notes_dir = vim.fn.expand('~/.nvimwiki')
|
||||
}
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = vim.tbl_extend('force', M.config, opts or {})
|
||||
end
|
||||
|
||||
function M.follow_link()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
local wiki_link = line:match('%[%[([^%]]+)%]%]')
|
||||
local md_link = line:match('%[.-%]%(([^%)])%)')
|
||||
|
||||
local link = wiki_link or md_link
|
||||
|
||||
if not link then return end
|
||||
|
||||
if not link:match('%.md$') then link = link .. '.md' end
|
||||
|
||||
if not link:match('^/') and not link:match('^%.') then
|
||||
local current_dir = vim.fn.expand('%:p:h')
|
||||
local relative_path = current_dir .. '/' .. link
|
||||
|
||||
-- if file exists, edit it in the buffer
|
||||
if vim.fn.filereadable(realative_path) then
|
||||
vim.cmd('edit' .. relative_path)
|
||||
return
|
||||
end
|
||||
|
||||
-- need to create file
|
||||
|
||||
target_path = M.config.notes_dir .. '/' .. link
|
||||
else
|
||||
target_path = link
|
||||
end
|
||||
|
||||
local parent_dir = vim.fn.fnamemodify(target_path, ':h')
|
||||
if vim.fn.isdirectory(parent_dir) == 0 then
|
||||
vim.fn.mkdir(parent_dir, 'p')
|
||||
end
|
||||
|
||||
vim.cmd('edit' .. link)
|
||||
end
|
||||
|
||||
function M.smart_link()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
local col = vim.api.nvim_win_get_cursor(0)[2]
|
||||
|
||||
local before = line:sub(1, col + 1)
|
||||
local after = line:sub(col + 1)
|
||||
|
||||
local in_wiki_link = before:match('%[%[[^%]]*$') and after:match('^[^%]]*%]%]')
|
||||
local in_md_link = before:match('%([^%)]*$') and after:match('^[^%)]*%)')
|
||||
|
||||
if in_wiki_link or in_md_link then
|
||||
M.follow_link()
|
||||
else
|
||||
local word = vim.fn.expand('<cWORD>')
|
||||
|
||||
word = word:match('[%w_/%-]+')
|
||||
|
||||
if word and word ~= '' then
|
||||
vim.cmd('normal! ciW[[' .. word .. ']]')
|
||||
vim.cmd('normal! F[')
|
||||
M.follow_link()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function M.setup_keymaps()
|
||||
vim.keymap.set('n', '<CR>', M.smart_link, { buffer = true, desc = "follow link"})
|
||||
vim.keymap.set('n', '<BS>', '<C-o>', { buffer = true, desc = "go back"})
|
||||
end
|
||||
|
||||
return M
|
||||
@ -6,6 +6,7 @@ return {
|
||||
priority = 1000,
|
||||
config = function()
|
||||
require("colors.hybrid").setup()
|
||||
require("transparency").setup()
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@ -39,7 +39,38 @@ return {
|
||||
end,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- filesystem = {
|
||||
-- components = {
|
||||
-- icon = function(config, node, state)
|
||||
-- local icon = config.default or " "
|
||||
-- local padding = config.padding or " "
|
||||
-- local highlight = config.highlight or highlights.FILE_ICON
|
||||
--
|
||||
-- if node.type == "directory" then
|
||||
-- highlight = highlights.DIRECTORY_ICON
|
||||
-- if node:is_expanded() then
|
||||
-- icon = config.folder_open or "-"
|
||||
-- else
|
||||
-- icon = config.folder_closed or "+"
|
||||
-- end
|
||||
-- elseif node.type == "file" then
|
||||
-- local success, web_devicons = pcall(require, "nvim-web-devicons")
|
||||
-- if success then
|
||||
-- local devicon, hl = web_devicons.get_icon(node.name, node.ext)
|
||||
-- icon = devicon or icon
|
||||
-- highlight = hl or highlight
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- return {
|
||||
-- text = icon .. padding,
|
||||
-- highlight = highlight,
|
||||
-- }
|
||||
-- end,
|
||||
-- }
|
||||
-- }
|
||||
})
|
||||
|
||||
-- auto open file tree on empty buffer or directory
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
@ -58,22 +89,5 @@ return {
|
||||
})
|
||||
end,
|
||||
lazy = false, -- neo-tree lazy loads itself
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "0.1.x",
|
||||
event = "VimEnter",
|
||||
dependencies = { "nvim-lua/plenary.nvim"},
|
||||
opts = {
|
||||
defaults = {
|
||||
layout_config = {
|
||||
horizontal = { width = 0.9 }
|
||||
},
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find files" },
|
||||
{ "<leader>s", "<cmd>Telescope spell_suggest<cr>", desc = "Spelling suggestions" },
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,22 @@ return {
|
||||
},
|
||||
}
|
||||
|
||||
-- Perl
|
||||
vim.lsp.config['perlnavigator'] = {
|
||||
root_markers = { ".git", ".svn" },
|
||||
-- init_options = {
|
||||
-- perlInc = false,
|
||||
-- },
|
||||
settings = {
|
||||
perlnavigator = {
|
||||
perlPath = '/usr/local/bin/p64',
|
||||
-- includePaths = {'/home/keegan/src/intex/fips/scripts/perlmodule'},
|
||||
perlcriticProfile = '/home/keegan/src/intex/binnt/perlcritic_config.txt',
|
||||
perltidyProfile = '/home/keegan/src/intex/binnt/perltidy_config',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Rust
|
||||
vim.lsp.config["rust_analyzer"] = {}
|
||||
|
||||
@ -47,6 +63,8 @@ return {
|
||||
-- TypeScript
|
||||
vim.lsp.config["tsls"] = {}
|
||||
|
||||
vim.lsp.enable({'perlnavigator', 'pylsp', 'tsls', 'rust_analyzer', 'lua_ls', 'clangd', 'gopls'})
|
||||
|
||||
-- Fix virtual text going off screen
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
|
||||
15
lua/plugins/nvimwiki.lua
Normal file
15
lua/plugins/nvimwiki.lua
Normal file
@ -0,0 +1,15 @@
|
||||
return {
|
||||
name = 'nvimwiki',
|
||||
dir = vim.fn.stdpath('config') ..'/lua',
|
||||
ft = 'markdown',
|
||||
opts = {
|
||||
notes_dir = '~/.nvimwiki',
|
||||
},
|
||||
keys = {
|
||||
{'<CR>', function() require('nvimwiki').smart_link() end, ft = 'markdown', desc = 'follow links'},
|
||||
{'<BS>', '<C-o>', ft = 'markdown', desc = 'go back'},
|
||||
},
|
||||
config = function(opts)
|
||||
require('nvimwiki').setup(opts)
|
||||
end,
|
||||
}
|
||||
51
lua/plugins/telescope.lua
Normal file
51
lua/plugins/telescope.lua
Normal file
@ -0,0 +1,51 @@
|
||||
function vim.find_files_from_project_git_root()
|
||||
local function is_git_repo()
|
||||
vim.fn.system("git rev-parse --is-inside-work-tree")
|
||||
return vim.v.shell_error == 0
|
||||
end
|
||||
local function is_svn_repo()
|
||||
vim.fn.system("svn info")
|
||||
return vim.v.shell_error == 0
|
||||
end
|
||||
local function get_git_root()
|
||||
local dot_git_path = vim.fn.finddir(".git", ".;")
|
||||
return vim.fn.fnamemodify(dot_git_path, ":h")
|
||||
end
|
||||
local function get_svn_root()
|
||||
local dot_svn_path = vim.fn.system("svn info --show-item wc-root")
|
||||
return vim.trim(dot_svn_path)
|
||||
end
|
||||
local opts = {}
|
||||
if is_git_repo() then
|
||||
opts = {
|
||||
cwd = get_git_root(),
|
||||
}
|
||||
elseif is_svn_repo() then
|
||||
opts = {
|
||||
cwd = get_svn_root(),
|
||||
}
|
||||
end
|
||||
require("telescope.builtin").find_files(opts)
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "0.1.x",
|
||||
event = "VimEnter",
|
||||
dependencies = { "nvim-lua/plenary.nvim"},
|
||||
opts = {
|
||||
defaults = {
|
||||
layout_config = {
|
||||
horizontal = { width = 0.9 }
|
||||
},
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files" },
|
||||
{ "<leader>F", vim.find_files_from_project_git_root, desc = "Find project files" },
|
||||
{ "<leader>fg", require("telescope.builtin").live_grep, desc = "Find inside files" },
|
||||
{ "<leader>s", "<cmd>Telescope spell_suggest<cr>", desc = "Spelling suggestions" },
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ return {
|
||||
ensure_installed = {
|
||||
"lua",
|
||||
"vim",
|
||||
"perl",
|
||||
"vimdoc",
|
||||
"javascript",
|
||||
"typescript",
|
||||
@ -26,10 +27,10 @@ return {
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<CR>",
|
||||
node_incremental = "<CR>",
|
||||
scope_incremental = "<S-CR>",
|
||||
node_decremental = "<BS>",
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
24
lua/transparency.lua
Normal file
24
lua/transparency.lua
Normal file
@ -0,0 +1,24 @@
|
||||
local M = {}
|
||||
|
||||
M.ToggleTransparent = function()
|
||||
M.Transparent = not M.Transparent
|
||||
if M.Transparent then
|
||||
vim.cmd("hi Normal ctermbg=NONE guibg=NONE")
|
||||
else
|
||||
-- 234 is hybrid dark bg color
|
||||
vim.cmd("hi Normal ctermbg=234 guibg='#1d1f21'")
|
||||
end
|
||||
end
|
||||
|
||||
M.setup = function()
|
||||
M.Transparent = false
|
||||
|
||||
-- if we have a display, set background to transparent
|
||||
if os.getenv("WAYLAND_DISPLAY") then
|
||||
M.ToggleTransparent()
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>b", M.ToggleTransparent)
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
x
Reference in New Issue
Block a user