+ :ZkOrphans :ZkGrep bracket & html matching

nix-components
pegasust 2022-08-31 07:39:47 -07:00
parent e7f3facc2c
commit fbbc1dea98
1 changed files with 235 additions and 197 deletions

View File

@ -74,6 +74,8 @@ Plug('hrsh7th/cmp-buffer')
Plug('hrsh7th/nvim-cmp') Plug('hrsh7th/nvim-cmp')
Plug('onsails/lspkind-nvim') Plug('onsails/lspkind-nvim')
-- DevExp -- DevExp
Plug('windwp/nvim-autopairs') -- matches pairs like [] (),...
Plug('windwp/nvim-ts-autotag') -- matches tags <body>hello</body>
Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines Plug('numToStr/Comment.nvim') -- "gc" to comment visual regions/lines
Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns Plug('lewis6991/gitsigns.nvim') -- add git info to sign columns
Plug('tpope/vim-fugitive') -- git commands in nvim Plug('tpope/vim-fugitive') -- git commands in nvim
@ -201,6 +203,7 @@ end, { desc = '[F]ind [D]iagnostics' })
-- treesitter -- treesitter
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' }, ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' },
sync_install = false,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
incremental_selection = { incremental_selection = {
@ -224,7 +227,16 @@ require('nvim-treesitter.configs').setup {
}, },
}, },
}, },
-- automatically close and modify HTML and TSX tags
autotag = {
enable = true,
},
} }
require('nvim-autopairs').setup {
check_ts = true,
}
-- harpoon: mark significant files & switch between them -- harpoon: mark significant files & switch between them
remap('n', '<leader>m', function() require('harpoon.mark').add_file() end) remap('n', '<leader>m', function() require('harpoon.mark').add_file() end)
local function harpoon_nav(key, nav_file_index, lead_keybind) local function harpoon_nav(key, nav_file_index, lead_keybind)
@ -233,6 +245,7 @@ local function harpoon_nav(key, nav_file_index, lead_keybind)
assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index") assert(type(nav_file_index) == "number" and nav_file_index >= 1, "expect 1-indexed number for file index")
return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end) return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end)
end end
-- remap letters to index. Inspired by alternating number of Dvorak programmer -- remap letters to index. Inspired by alternating number of Dvorak programmer
-- best practices: try to keep marked files to be around 4 -- best practices: try to keep marked files to be around 4
harpoon_nav('f', 1) harpoon_nav('f', 1)
@ -358,6 +371,32 @@ require('zk').setup({
}, },
}) })
-- Custom ZkOrphans that determines unlinked notes
-- `:ZkOrphans {tags = {"work"}}`
require('zk.commands').add("ZkOrphans", function(options)
options = vim.tbl_extend("force", { orphan = true }, options or {})
-- zk.edit opens notes picker
require('zk').edit(options, { title = "Zk Orphans (unlinked notes)" })
end)
-- ZkGrep: opens file picker
-- In the case where `match_ctor` is falsy, create a prompt.
-- This is so that we distinguish between ZkGrep and ZkNotes
-- Params:
-- match_ctor: string | {match= :string,...} | "" | nil
require('zk.commands').add("ZkGrep", function(match_ctor)
-- handle polymorphic `match_ctor`
local grep_str = ""
local match
if match_ctor == nil or match_ctor == '' then
vim.fn.inputsave()
grep_str = vim.fn.input('Grep string: >')
vim.fn.inputrestore()
match = { match = grep_str }
end
require('zk').edit(match, { title = "Grep: '" .. grep_str .. "'" })
end)
-- nvim-cmp -- nvim-cmp
local cmp = require 'cmp' local cmp = require 'cmp'
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
@ -416,4 +455,3 @@ require('lualine').setup {
icons_enabled = true, icons_enabled = true,
}, },
} }