+ :ZkOrphans :ZkGrep bracket & html matching
parent
e7f3facc2c
commit
fbbc1dea98
|
@ -74,6 +74,8 @@ Plug('hrsh7th/cmp-buffer')
|
|||
Plug('hrsh7th/nvim-cmp')
|
||||
Plug('onsails/lspkind-nvim')
|
||||
-- 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('lewis6991/gitsigns.nvim') -- add git info to sign columns
|
||||
Plug('tpope/vim-fugitive') -- git commands in nvim
|
||||
|
@ -201,6 +203,7 @@ end, { desc = '[F]ind [D]iagnostics' })
|
|||
-- treesitter
|
||||
require('nvim-treesitter.configs').setup {
|
||||
ensure_installed = { 'lua', 'typescript', 'rust', 'go', 'python', 'prisma' },
|
||||
sync_install = false,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
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
|
||||
remap('n', '<leader>m', function() require('harpoon.mark').add_file() end)
|
||||
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")
|
||||
return remap('n', lead_keybind .. key, function() require('harpoon.ui').nav_file(nav_file_index) end)
|
||||
end
|
||||
|
||||
-- remap letters to index. Inspired by alternating number of Dvorak programmer
|
||||
-- best practices: try to keep marked files to be around 4
|
||||
harpoon_nav('f', 1)
|
||||
|
@ -241,16 +254,16 @@ harpoon_nav('d', 3)
|
|||
harpoon_nav('k', 4)
|
||||
remap('n', '<leader>hh', function() require('harpoon.ui').toggle_quick_menu() end)
|
||||
-- harpoon: navigate by numbers
|
||||
harpoon_nav('1',1)
|
||||
harpoon_nav('2',2)
|
||||
harpoon_nav('3',3)
|
||||
harpoon_nav('4',4)
|
||||
harpoon_nav('5',5)
|
||||
harpoon_nav('6',6)
|
||||
harpoon_nav('7',7)
|
||||
harpoon_nav('8',8)
|
||||
harpoon_nav('9',9)
|
||||
harpoon_nav('0',10)
|
||||
harpoon_nav('1', 1)
|
||||
harpoon_nav('2', 2)
|
||||
harpoon_nav('3', 3)
|
||||
harpoon_nav('4', 4)
|
||||
harpoon_nav('5', 5)
|
||||
harpoon_nav('6', 6)
|
||||
harpoon_nav('7', 7)
|
||||
harpoon_nav('8', 8)
|
||||
harpoon_nav('9', 9)
|
||||
harpoon_nav('0', 10)
|
||||
|
||||
-- LSP settings
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
|
@ -347,17 +360,43 @@ require('zk').setup({
|
|||
picker = "telescope",
|
||||
lsp = {
|
||||
config = {
|
||||
cmd = {"zk", "lsp"},
|
||||
cmd = { "zk", "lsp" },
|
||||
name = "zk",
|
||||
on_attach = on_attach,
|
||||
},
|
||||
auto_attach = {
|
||||
enable = true,
|
||||
filetypes = {"markdown"}
|
||||
filetypes = { "markdown" }
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- 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
|
||||
local cmp = require 'cmp'
|
||||
local luasnip = require 'luasnip'
|
||||
|
@ -416,4 +455,3 @@ require('lualine').setup {
|
|||
icons_enabled = true,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue