diff --git a/init.lua b/init.lua index 406be44..f14127e 100644 --- a/init.lua +++ b/init.lua @@ -174,6 +174,11 @@ vim.opt.expandtab = true -- See `:help hlsearch` vim.keymap.set('n', '', 'nohlsearch') +vim.keymap.set('n', 'q:', '') +vim.keymap.set('n', 'q/', '') +vim.keymap.set('n', 'q?', '') +vim.keymap.set('c', '', '') + -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) @@ -363,7 +368,7 @@ require('lazy').setup({ { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', event = 'VimEnter', - branch = '0.1.x', + branch = 'master', dependencies = { 'nvim-lua/plenary.nvim', { -- If encountering errors, see telescope-fzf-native README for installation instructions @@ -676,6 +681,9 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { clangd = {}, + verible = { + cmd = { 'verible-verilog-ls', '--rules_config_search' }, + }, -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, @@ -718,7 +726,7 @@ require('lazy').setup({ return nil end - local xml_path = vim.fn.stdpath('cache') .. '/jdtls-formatter-' .. vim.fn.sha256(props_path) .. '.xml' + local xml_path = vim.fn.stdpath 'cache' .. '/jdtls-formatter-' .. vim.fn.sha256(props_path) .. '.xml' local xml_stat = fs.fs_stat(xml_path) if not xml_stat or xml_stat.mtime.sec < stat.mtime.sec then local lines = { @@ -727,8 +735,8 @@ require('lazy').setup({ '', } for line in io.lines(props_path) do - local key, value = line:match('^%s*([^=%s]+)%s*=%s*(.-)%s*$') - if key and not key:match('^#') then + local key, value = line:match '^%s*([^=%s]+)%s*=%s*(.-)%s*$' + if key and not key:match '^#' then value = value:gsub('&', '&'):gsub('"', '"'):gsub('<', '<'):gsub('>', '>') table.insert(lines, string.format('', key, value)) end @@ -1028,29 +1036,34 @@ require('lazy').setup({ }, { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', + branch = 'main', + lazy = false, build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - disable = { 'latex' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + config = function() + local ts = require 'nvim-treesitter' + ts.setup() + ts.install { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } + + vim.api.nvim_create_autocmd('FileType', { + callback = function(args) + local lang = vim.treesitter.language.get_lang(args.match) + if not lang then + return + end + if not pcall(vim.treesitter.start, args.buf, lang) then + if vim.tbl_contains(ts.get_available(), lang) then + ts.install(lang):await(function() + if vim.api.nvim_buf_is_valid(args.buf) then + pcall(vim.treesitter.start, args.buf, lang) + end + end) + end + return + end + vim.bo[args.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, + }) + end, }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 0000000..0723da0 --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,58 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim' }, + config = function() + local harpoon = require 'harpoon' + harpoon:setup() + + local conf = require('telescope.config').values + local function toggle_telescope(harpoon_files) + local file_paths = {} + local index_map = {} + for i = 1, harpoon_files:length() do + local item = harpoon_files:get(i) + if item then + table.insert(file_paths, item.value) + table.insert(index_map, i) + end + end + + require('telescope.pickers') + .new({}, { + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table { + results = file_paths, + }, + previewer = conf.file_previewer {}, + sorter = conf.generic_sorter {}, + attach_mappings = function(prompt_bufnr, map) + local actions = require 'telescope.actions' + local action_state = require 'telescope.actions.state' + local function delete_mark() + local selection = action_state.get_selected_entry() + harpoon:list():remove_at(index_map[selection.index]) + actions.close(prompt_bufnr) + toggle_telescope(harpoon:list()) + end + map('i', '', delete_mark) + map('n', '', delete_mark) + return true + end, + }) + :find() + end + + vim.keymap.set('n', 'a', function() harpoon:list():add() end, { desc = 'Harpoon Add File' }) + vim.keymap.set('n', 'rm', function() harpoon:list():remove() end, { desc = 'Harpoon Remove Current File' }) + vim.keymap.set('n', '', function() toggle_telescope(harpoon:list()) end, { desc = 'Harpoon Quick Menu (Telescope)' }) + + vim.keymap.set('n', '', function() harpoon:list():select(1) end, { desc = 'Harpoon to File 1' }) + vim.keymap.set('n', '', function() harpoon:list():select(2) end, { desc = 'Harpoon to File 2' }) + vim.keymap.set('n', '', function() harpoon:list():select(3) end, { desc = 'Harpoon to File 3' }) + vim.keymap.set('n', '', function() harpoon:list():select(4) end, { desc = 'Harpoon to File 4' }) + + vim.keymap.set('n', '', function() harpoon:list():prev() end, { desc = 'Harpoon Prev' }) + vim.keymap.set('n', '', function() harpoon:list():next() end, { desc = 'Harpoon Next' }) + end, +}