diff --git a/lua/colors/hybrid.lua b/lua/colors/hybrid.lua index 923d38a..de217b3 100644 --- a/lua/colors/hybrid.lua +++ b/lua/colors/hybrid.lua @@ -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 }) diff --git a/lua/config/keymap.lua b/lua/config/keymap.lua index ca6ff74..51b857c 100644 --- a/lua/config/keymap.lua +++ b/lua/config/keymap.lua @@ -3,18 +3,23 @@ vim.g.mapleader = " " -- disable vim copying via windows cmd for system takeover -- vim.keymap.set({"n","v","i"},"",'', { 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", "b", ":lua ToggleTransparent()") +vim.keymap.set("n", "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", "a", ":lua SpellToggle()") +vim.keymap.set("n", "a", SpellToggle) -- markdown preview vim.keymap.set("n", "p", ":MarkdownPreviewToggle") diff --git a/lua/config/options.lua b/lua/config/options.lua index 5d7b5a2..767d90f 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -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 +-- ]]) diff --git a/lua/nvimwiki.lua b/lua/nvimwiki.lua new file mode 100644 index 0000000..84be2b7 --- /dev/null +++ b/lua/nvimwiki.lua @@ -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('') + + 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', '', M.smart_link, { buffer = true, desc = "follow link"}) + vim.keymap.set('n', '', '', { buffer = true, desc = "go back"}) +end + +return M diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 02b8652..eb02024 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -6,6 +6,7 @@ return { priority = 1000, config = function() require("colors.hybrid").setup() + require("transparency").setup() end, }, } diff --git a/lua/plugins/filetree.lua b/lua/plugins/filetree.lua index 5a90d84..c6607b8 100644 --- a/lua/plugins/filetree.lua +++ b/lua/plugins/filetree.lua @@ -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 = { - { "f", "Telescope find_files", desc = "Find files" }, - { "s", "Telescope spell_suggest", desc = "Spelling suggestions" }, - }, } } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 4170e8c..1dcb8b9 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -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, diff --git a/lua/plugins/nvimwiki.lua b/lua/plugins/nvimwiki.lua new file mode 100644 index 0000000..2ee21b6 --- /dev/null +++ b/lua/plugins/nvimwiki.lua @@ -0,0 +1,15 @@ +return { + name = 'nvimwiki', + dir = vim.fn.stdpath('config') ..'/lua', + ft = 'markdown', + opts = { + notes_dir = '~/.nvimwiki', + }, + keys = { + {'', function() require('nvimwiki').smart_link() end, ft = 'markdown', desc = 'follow links'}, + {'', '', ft = 'markdown', desc = 'go back'}, + }, + config = function(opts) + require('nvimwiki').setup(opts) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..0c07d90 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -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 = { + { "ff", "Telescope find_files", desc = "Find files" }, + { "F", vim.find_files_from_project_git_root, desc = "Find project files" }, + { "fg", require("telescope.builtin").live_grep, desc = "Find inside files" }, + { "s", "Telescope spell_suggest", desc = "Spelling suggestions" }, + }, + } +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index c64eb27..3fa8777 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -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 = "", - node_incremental = "", - scope_incremental = "", - node_decremental = "", + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", }, }, }) diff --git a/lua/transparency.lua b/lua/transparency.lua new file mode 100644 index 0000000..6b67699 --- /dev/null +++ b/lua/transparency.lua @@ -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", "b", M.ToggleTransparent) +end + +return M