aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--snippets/html_script1
-rw-r--r--snippets/html_template_map_leaderline135
-rw-r--r--vim/init/config.vim2
-rw-r--r--vim/init/keymaps.vim6
-rw-r--r--vim/mini.lua102
5 files changed, 191 insertions, 55 deletions
diff --git a/snippets/html_script b/snippets/html_script
new file mode 100644
index 0000000..f975727
--- /dev/null
+++ b/snippets/html_script
@@ -0,0 +1 @@
<script src="./index.js"></script>
diff --git a/snippets/html_template_map_leaderline b/snippets/html_template_map_leaderline
new file mode 100644
index 0000000..afcec6d
--- /dev/null
+++ b/snippets/html_template_map_leaderline
@@ -0,0 +1,135 @@
1<!DOCTYPE html>
2<html lang="en">
3
4<head>
5 <meta charset='utf-8'>
6 <title>Leader Line with Markdown</title>
7
8 <meta property="og:description" content="Add a default marker to the map." />
9 <meta name="viewport" content="width=device-width, initial-scale=1">
10
11 <link rel='stylesheet' href='https://unpkg.com/maplibre-gl@4.5.2/dist/maplibre-gl.css' />
12
13 <script src='https://unpkg.com/maplibre-gl@4.5.2/dist/maplibre-gl.js'></script>
14 <script src='https://cdnjs.cloudflare.com/ajax/libs/leader-line/1.0.7/leader-line.min.js'></script>
15 <script src='https://cdnjs.cloudflare.com/ajax/libs/marked/14.0.0/marked.min.js'></script>
16 <style>
17 body {
18 margin: 0;
19 padding: 0;
20 display: flex;
21 }
22
23 html,
24 body,
25 #map,
26 #markdown {
27 height: 100%;
28 }
29
30 #map,
31 #markdown {
32 flex: 50%;
33 }
34
35 pre {
36 display: none;
37 }
38 </style>
39</head>
40
41<body>
42 <div id="map"></div>
43 <div id="markdown"></div>
44 <pre id="markdown-raw"># Some Markdown rendered Content
45[Place 1]
46
47## Title 2
48
49- item
50- subitem
51- subusb
52
53Text before link [Place 2]
54![](https://i.ibb.co/3N65X9n/2021-05-27-6-21-48.png)
55
56[Place 1]: geo:12.55,55.66
57[Place 2]: geo:13,55.8
58 </pre>
59
60 <script>
61 const map = new maplibregl.Map({
62 container: 'map',
63 style:
64 'https://raw.githubusercontent.com/maplibre/demotiles/gh-pages/style.json',
65 center: [12.550343, 55.665957],
66 zoom: 8
67 });
68
69 document.getElementById('markdown').innerHTML = marked.parse(document.getElementById('markdown-raw').innerHTML);
70
71 const links = Array.from(document.querySelectorAll('#markdown a'))
72 links.forEach(link => {
73 let location = link.href.split('geo:')[1]
74 let lon = Number(location.split(',')[0])
75 let lat = Number(location.split(',')[1])
76 link.marker = new maplibregl.Marker()
77 .setLngLat([lon, lat])
78 .addTo(map)
79 .getElement()
80
81 link.line = new LeaderLine(
82 link,
83 // LeaderLine.mouseHoverAnchor(link),
84 // line.marker.getElement(),
85 LeaderLine.areaAnchor(link.marker, 'circle'),
86 {
87 middleLabel: LeaderLine.captionLabel('MIDDLE'),
88 offset: [-20, 0],
89 startSocket: 'auto',
90 }
91 )
92 link.line.hide()
93
94 link.visibility = false
95
96 link.addEventListener("click", (event) => {
97 link.visibility ? link.line.hide() : link.line.show()
98 // if (link.visibility) {
99 // link.line.hide()
100 // }
101 // else {
102 // link.line.show()
103 // }
104 link.visibility = !link.visibility
105 })
106 })
107
108 function isChildOutsideParent(childElement, parentElement) {
109 // 获取边界框信息
110 const childRect = childElement.getBoundingClientRect();
111 const parentRect = parentElement.getBoundingClientRect();
112
113 return (
114 childRect.left < parentRect.left ||
115 childRect.right > parentRect.right ||
116 childRect.top < parentRect.top ||
117 childRect.bottom > parentRect.bottom
118 );
119 }
120 map.on('move', () => {
121 links.forEach(link => {
122 if (isChildOutsideParent(link.marker, map.getCanvas())) {
123 link.line.hide()
124 return
125 } else {
126 if (link.visibility) link.line.show()
127 }
128 link.line.position()
129 })
130 })
131
132 </script>
133</body>
134
135</html>
diff --git a/vim/init/config.vim b/vim/init/config.vim
index de7ee22..74cbd39 100644
--- a/vim/init/config.vim
+++ b/vim/init/config.vim
@@ -24,7 +24,7 @@ augroup TerminalSize
24 endif 24 endif
25 endfunc 25 endfunc
26 autocmd VimEnter,VimResized * silent call LayoutForSmallTerminal(20) 26 autocmd VimEnter,VimResized * silent call LayoutForSmallTerminal(20)
27 autocmd VimLeave * if g:alacritty_extra_padding | call ToggleWinPadding() | endif 27 autocmd VimLeave,VimSuspend * if g:alacritty_extra_padding | silent call ToggleWinPadding(100) | endif
28augroup END 28augroup END
29 29
30" }}} 30" }}}
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim
index a6f75e5..c0af8c8 100644
--- a/vim/init/keymaps.vim
+++ b/vim/init/keymaps.vim
@@ -756,9 +756,9 @@ nnoremap <leader><leader>rtp :Redir echo &rtp<CR>:s/,/\r/g<CR>
756 756
757let g:tig_explorer_keymap_commit_split = '<C-s>' 757let g:tig_explorer_keymap_commit_split = '<C-s>'
758let g:tig_explorer_keymap_commit_vsplit = '<C-v>' 758let g:tig_explorer_keymap_commit_vsplit = '<C-v>'
759nnoremap <C-t> <Cmd>Tig<CR> 759nnoremap <C-t> <Cmd>silent! Tig<CR>
760nnoremap <C-t>s <Cmd>TigStatus<CR> 760nnoremap <C-t>s <Cmd>silent! TigStatus<CR>
761nnoremap <C-t>b <Cmd>TigBlame<CR> 761nnoremap <C-t>b <Cmd>silent! TigBlame<CR>
762 762
763" }}} 763" }}}
764" Tmp: Common system command {{{ 764" Tmp: Common system command {{{
diff --git a/vim/mini.lua b/vim/mini.lua
index 6f7ba57..92f9efe 100644
--- a/vim/mini.lua
+++ b/vim/mini.lua
@@ -983,24 +983,24 @@ require("lazy").setup({
983 end, 983 end,
984 }, 984 },
985 -- }}} 985 -- }}}
986 -- markview.nvim {{{ 986 -- -- markview.nvim {{{
987 { 987 -- {
988 "OXY2DEV/markview.nvim", 988 -- "OXY2DEV/markview.nvim",
989 lazy = false, 989 -- lazy = false,
990 ft = "markdown", 990 -- ft = "markdown",
991 991 --
992 dependencies = { 992 -- dependencies = {
993 -- You may not need this if you don't lazy load 993 -- -- You may not need this if you don't lazy load
994 -- Or if the parsers are in your $RUNTIMEPATH 994 -- -- Or if the parsers are in your $RUNTIMEPATH
995 "nvim-treesitter/nvim-treesitter", 995 -- "nvim-treesitter/nvim-treesitter",
996 996 --
997 "nvim-tree/nvim-web-devicons" 997 -- "nvim-tree/nvim-web-devicons"
998 }, 998 -- },
999 config = function() 999 -- config = function()
1000 vim.keymap.set('n', '\\m', ":Markview<CR>", { buffer = bufnr, desc = '' }) 1000 -- vim.keymap.set('n', '\\m', ":Markview<CR>", { buffer = bufnr, desc = '' })
1001 end 1001 -- end
1002 }, 1002 -- },
1003 -- }}} 1003 -- -- }}}
1004 1004
1005 -- lspconfig {{{ 1005 -- lspconfig {{{
1006 -- Use :help lspconfig-all to check servers 1006 -- Use :help lspconfig-all to check servers
@@ -1412,39 +1412,39 @@ require("lazy").setup({
1412 }, 1412 },
1413 1413
1414 -- }}} 1414 -- }}}
1415 -- lspsaga {{{ 1415 -- -- lspsaga {{{
1416 { 1416 -- {
1417 'nvimdev/lspsaga.nvim', 1417 -- 'nvimdev/lspsaga.nvim',
1418 dependencies = { 1418 -- dependencies = {
1419 'nvim-treesitter/nvim-treesitter', -- optional 1419 -- 'nvim-treesitter/nvim-treesitter', -- optional
1420 'nvim-tree/nvim-web-devicons', -- optional 1420 -- 'nvim-tree/nvim-web-devicons', -- optional
1421 }, 1421 -- },
1422 config = function() 1422 -- config = function()
1423 require('lspsaga').setup({ 1423 -- require('lspsaga').setup({
1424 autochdir = true, 1424 -- autochdir = true,
1425 }) 1425 -- })
1426 vim.api.nvim_create_autocmd("LspAttach", { 1426 -- vim.api.nvim_create_autocmd("LspAttach", {
1427 group = custom_autocommands, 1427 -- group = custom_autocommands,
1428 pattern = "*", 1428 -- pattern = "*",
1429 callback = function(args) 1429 -- callback = function(args)
1430 local map = vim.api.nvim_buf_set_keymap 1430 -- local map = vim.api.nvim_buf_set_keymap
1431 map(0, "n", "gd", "<cmd>Lspsaga goto_definition<cr>", { silent = true, noremap = true }) 1431 -- map(0, "n", "gd", "<cmd>Lspsaga goto_definition<cr>", { silent = true, noremap = true })
1432 map(0, "n", "gR", "<cmd>Lspsaga rename<cr>", { silent = true, noremap = true }) 1432 -- map(0, "n", "gR", "<cmd>Lspsaga rename<cr>", { silent = true, noremap = true })
1433 map(0, "n", "gx", "<cmd>Lspsaga code_action<cr>", { silent = true, noremap = true }) 1433 -- map(0, "n", "gx", "<cmd>Lspsaga code_action<cr>", { silent = true, noremap = true })
1434 map(0, "x", "gx", ":<c-u>Lspsaga range_code_action<cr>", { silent = true, noremap = true }) 1434 -- map(0, "x", "gx", ":<c-u>Lspsaga range_code_action<cr>", { silent = true, noremap = true })
1435 map(0, "n", "K", "<cmd>Lspsaga hover_doc<cr>", { silent = true, noremap = true }) 1435 -- map(0, "n", "K", "<cmd>Lspsaga hover_doc<cr>", { silent = true, noremap = true })
1436 map(0, "n", "go", "<cmd>Lspsaga show_line_diagnostics<cr>", { silent = true, noremap = true }) 1436 -- map(0, "n", "go", "<cmd>Lspsaga show_line_diagnostics<cr>", { silent = true, noremap = true })
1437 map(0, "n", "gj", "<cmd>Lspsaga diagnostic_jump_next<cr>", { silent = true, noremap = true }) 1437 -- map(0, "n", "gj", "<cmd>Lspsaga diagnostic_jump_next<cr>", { silent = true, noremap = true })
1438 map(0, "n", "gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>", { silent = true, noremap = true }) 1438 -- map(0, "n", "gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>", { silent = true, noremap = true })
1439 1439 --
1440 -- Don't know why... Everytime when modeline is set and insert a single char 1440 -- -- Don't know why... Everytime when modeline is set and insert a single char
1441 -- while inside a fold, the fold closes. 1441 -- -- while inside a fold, the fold closes.
1442 vim.opt_local.modeline = false 1442 -- vim.opt_local.modeline = false
1443 end, 1443 -- end,
1444 }) 1444 -- })
1445 end 1445 -- end
1446 }, 1446 -- },
1447 -- }}} 1447 -- -- }}}
1448 -- -- conform {{{ 1448 -- -- conform {{{
1449 -- { 1449 -- {
1450 -- "stevearc/conform.nvim", 1450 -- "stevearc/conform.nvim",