Skip to content

Commit dac9326

Browse files
committed
hop1 bugfix for keymap
1 parent 1001310 commit dac9326

File tree

10 files changed

+271
-26
lines changed

10 files changed

+271
-26
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
*.log

lua/keymap/init.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ local plug_map = {
3939
["n|<Leader>cl"] = map_cr('<cmd>lua require("telescope").extensions.neoclip.default()'):with_silent(),
4040
["n|<Leader>fz"] = map_cr('<cmd>lua require("telescope").extensions.zoxide.list()'):with_silent(),
4141
["n|<Leader>fp"] = map_cr('<cmd>lua require("telescope").extensions.projects.projects()'):with_silent(),
42-
-- ["n|<Leader>fw"] = map_cu('Telescope grep_string'):with_noremap():with_silent(),
42+
["n|<Leader>fw"] = map_cu('Telescope grep_string'):with_noremap():with_silent(),
4343
["n|<Leader>fl"] = map_cu('Telescope loclist'):with_noremap():with_silent(),
4444
["n|<Leader>fc"] = map_cu('Telescope git_commits'):with_noremap():with_silent(),
4545
["n|<Leader>ft"] = map_cu('Telescope help_tags'):with_noremap():with_silent(),
@@ -50,7 +50,7 @@ local plug_map = {
5050
-- ["in|<d-f>"] = map_cr("<cmd> lua require'telescope.builtin'.grep_string({defulat_text=vim.fn.expand('cword')})"):with_noremap()
5151
-- :with_silent(),
5252

53-
["in|<d-f>"] = map_cmd([['<cmd>lua require"telescope.builtin".grep_string()<cr>' . expand('<cword>')]]):with_expr()
53+
["in|<d-f>"] = map_cmd([['<cmd>lua require"telescope.builtin".live_grep()<cr>' . expand('<cword>')]]):with_expr()
5454
:with_silent(),
5555
-- :with_expr(),
5656
-- ["in|<d-f>"] = map_cmd([[ ':Telescope live_grep<cr>' . expand('<cword>')]]):with_expr():with_silent(),

lua/modules/completion/config.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ function config.nvim_cmp()
144144
},
145145

146146
-- You should specify your *installed* sources.
147-
sources = sources
147+
sources = sources,
148+
149+
experimental = {ghost_text = true}
148150
}
151+
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
152+
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({map_char = {tex = ''}}))
149153

150154
-- require'cmp'.setup.cmdline(':', {sources = {{name = 'cmdline'}}})
151155
if vim.o.ft == 'clap_input' or vim.o.ft == 'guihua' or vim.o.ft == 'guihua_rust' then

lua/modules/completion/plugins.lua

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ completion[plugin_folder() .. "lsp_signature.nvim"] = {
125125
config = function()
126126
require"lsp_signature".setup({
127127
bind = true,
128+
-- doc_lines = 4,
128129
toggle_key = '<M-x>',
129130
floating_window = true,
130131
floating_window_above_cur_line = true,

lua/modules/tools/plugins.lua

+9
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ tools["lewis6991/gitsigns.nvim"] = {
145145
opt = true
146146
}
147147

148+
local path = plugin_folder()
149+
tools[path .. "sad.nvim"] = {
150+
cmd = {'Sad'},
151+
opt = true,
152+
config = function()
153+
require'sad'.setup({debug = true, log_path = "~/tmp/sad.log"})
154+
end
155+
}
156+
148157
-- early stage...
149158
tools['tanvirtin/vgit.nvim'] = { -- gitsign has similar features
150159
setup = function()

lua/overwrite/mapping.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ local keys = {
8282
["xon|F"] = map_cmd("<cmd>lua Line_ft('F')<cr>"),
8383
["xon|t"] = map_cmd("<cmd>lua Line_ft('t')<cr>"),
8484
["xon|T"] = map_cmd("<cmd>lua Line_ft('T')<cr>"),
85-
["n|s"] = map_cmd("<cmd>lua hop1(1)<cr>"),
86-
["n|S"] = map_cmd("<cmd>lua hop1()<cr>"),
85+
["n|s"] = map_cmd("<cmd>lua hop1(1)<CR>"):with_silent(),
86+
["n|S"] = map_cmd("<cmd>lua hop1()<CR>"):with_silent(),
8787
["x|s"] = map_cmd("<cmd>lua hop1(1)<CR>"):with_silent(),
8888
["x|S"] = map_cmd("<cmd>lua hop1()<CR>"):with_silent(),
8989
-- ["v|<M-s>"] = map_cmd("<cmd>lua require'hop'.hint_char1()<cr>"):with_silent():with_expr(),
@@ -124,7 +124,9 @@ local keys = {
124124
["n|<Space>m"] = map_cmd([[<cmd> Telescope harpoon marks <CR>]]),
125125
["v|<Leader>re"] = map_cmd("<esc><cmd>lua require('refactoring').refactor('Extract Function')<cr>"),
126126
["v|<Leader>rf"] = map_cmd("<esc><cmd>lua require('refactoring').refactor('Extract Function To File')<cr>"),
127-
["v|<Leader>rt"] = map_cmd("<esc><cmd>lua require('refactoring').refactor()<cr>")
127+
["v|<Leader>rt"] = map_cmd("<esc><cmd>lua require('refactoring').refactor()<cr>"),
128+
129+
["v|<Leader>gs"] = map_cmd("<cmd>lua require('utils.git').qf_add()<cr>")
128130

129131
}
130132

@@ -184,15 +186,13 @@ _G.hop1 = function(ac)
184186
loader('hop')
185187
end
186188
if vim.fn.mode() == 's' then
187-
print(vim.fn.mode(), vim.fn.mode() == 's')
189+
-- print(vim.fn.mode(), vim.fn.mode() == 's')
188190
return vim.cmd('exe "normal! i s"')
189-
else
190-
print(vim.fn.mode(), vim.fn.mode() == 's')
191191
end
192192
if ac == 1 then
193193
require'hop'.hint_char1({direction = require'hop.hint'.HintDirection.AFTER_CURSOR})
194194
else
195-
require'hop'.hint_char1({direction = require'hop.hint'.HintDirection.AFTER_CURSOR})
195+
require'hop'.hint_char1({direction = require'hop.hint'.HintDirection.BEFORE_CURSOR})
196196
end
197197
end
198198

lua/utils/git.lua

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
M = {}
2+
local parse_changes = function()
3+
local status = vim.fn.system "git status --porcelain"
4+
5+
local changes = vim.split(vim.trim(status), "\n")
6+
7+
return changes
8+
end
9+
10+
-- https://github.com/rmagatti/igs.nvim/
11+
-- send changed file to qf
12+
13+
M.qf_add = function(type)
14+
type = type or 'all'
15+
local changes = parse_changes()
16+
local qflist_what = {}
17+
18+
for _, change in ipairs(changes) do
19+
local change_type = vim.trim(change:sub(1, 1))
20+
local file_path = vim.trim(change:sub(3))
21+
22+
if type == "all" then
23+
local bufnr = vim.fn.bufadd(file_path)
24+
table.insert(qflist_what, {bufnr = bufnr, lnum = 0, col = 0})
25+
elseif change_type == type then
26+
local bufnr = vim.fn.bufadd(file_path)
27+
table.insert(qflist_what, {bufnr = bufnr, lnum = 0, col = 0})
28+
end
29+
end
30+
31+
if vim.tbl_isempty(qflist_what) then
32+
return
33+
end
34+
35+
vim.fn.setqflist(qflist_what)
36+
37+
vim.cmd [[copen]]
38+
end
39+
return M

min/init_pack.lua

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
local fn = vim.fn
2+
local packer_dir = fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim'
3+
4+
if fn.empty(fn.glob(packer_dir)) > 0 then
5+
packer_bootstrap = fn.system {
6+
'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', packer_dir
7+
}
8+
end
9+
10+
Plugin_folder = [[~/github/]] -- vim.fn.expand("$HOME") .. '/github/'
11+
12+
vim.cmd [[packadd packer.nvim]]
13+
packer = require('packer')
14+
packer.startup({
15+
function()
16+
use {'wbthomason/packer.nvim', opt = true}
17+
18+
use {'neovim/nvim-lspconfig'}
19+
use {'ray-x/lsp_signature.nvim'}
20+
21+
use {'hrsh7th/nvim-cmp'}
22+
use {'hrsh7th/cmp-nvim-lsp'}
23+
24+
use {'L3MON4D3/LuaSnip'}
25+
use {'saadparwaiz1/cmp_luasnip'}
26+
27+
use {'windwp/nvim-autopairs'}
28+
end,
29+
config = {
30+
display = {
31+
open_fn = function()
32+
return require("packer.util").float({border = "single"})
33+
end
34+
}
35+
}
36+
})
37+
38+
if packer_bootstrap then
39+
packer.sync()
40+
end
41+
42+
local has_words_before = function()
43+
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
44+
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
45+
end
46+
47+
local loader = require"packer".loader
48+
49+
local cmp = require('cmp')
50+
cmp.setup {
51+
mapping = {
52+
["<CR>"] = cmp.mapping.confirm({select = true}),
53+
["<C-p>"] = cmp.mapping.select_prev_item(),
54+
["<C-n>"] = cmp.mapping.select_next_item(),
55+
["<C-d>"] = cmp.mapping.scroll_docs(-4),
56+
["<C-f>"] = cmp.mapping.scroll_docs(4),
57+
["<C-e>"] = cmp.mapping.close(),
58+
["<Tab>"] = cmp.mapping(function(fallback)
59+
if cmp.visible() then
60+
cmp.select_next_item()
61+
elseif require('luasnip').expand_or_jumpable() then
62+
require('luasnip').expand_or_jump()
63+
elseif has_words_before() then
64+
cmp.complete()
65+
else
66+
fallback()
67+
end
68+
end, {"i", "s"}),
69+
["<S-Tab>"] = cmp.mapping(function(fallback)
70+
if cmp.visible() then
71+
cmp.select_prev_item()
72+
elseif require('luasnip').jumpable(-1) then
73+
require('luasnip').jump(-1)
74+
else
75+
fallback()
76+
end
77+
end, {"i", "s"})
78+
},
79+
snippet = {
80+
expand = function(args)
81+
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
82+
end
83+
},
84+
sources = {{name = 'nvim_lsp'}, {name = 'luasnip'}},
85+
completion = {completeopt = 'menu,menuone,noinsert'},
86+
experimental = {ghost_text = true}
87+
}
88+
89+
require("luasnip").config.set_config {history = true, updateevents = "TextChanged,TextChangedI"}
90+
require("luasnip.loaders.from_vscode").load()
91+
92+
require('nvim-autopairs').setup()
93+
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
94+
cmp = require('cmp')
95+
96+
-- vim.cmd('packadd lsp_signature.nvim')
97+
require'lspconfig'.gopls.setup {}
98+
require"lsp_signature".setup {}
99+
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({map_char = {tex = ''}}))
100+
vim.cmd('set mouse=a')

min/init_paq.lua

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
local fn = vim.fn
2+
3+
local install_path = fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim'
4+
5+
if fn.empty(fn.glob(install_path)) > 0 then
6+
fn.system({'git', 'clone', '--depth=1', 'https://github.com/savq/paq-nvim.git', install_path})
7+
end
8+
9+
require "paq" {
10+
"savq/paq-nvim", -- Let Paq manage itself
11+
"neovim/nvim-lspconfig", -- Mind the semi-colons
12+
"hrsh7th/nvim-cmp", -- Use braces when passing options
13+
"ray-x/lsp_signature.nvim", "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip",
14+
"saadparwaiz1/cmp_luasnip", "windwp/nvim-autopairs"
15+
}
16+
vim.cmd([[colorscheme darkblue]])
17+
18+
local cmp = require('cmp')
19+
cmp.setup {
20+
mapping = {
21+
["<CR>"] = cmp.mapping.confirm({select = true}),
22+
["<C-p>"] = cmp.mapping.select_prev_item(),
23+
["<C-n>"] = cmp.mapping.select_next_item(),
24+
["<C-d>"] = cmp.mapping.scroll_docs(-4),
25+
["<C-f>"] = cmp.mapping.scroll_docs(4),
26+
["<C-e>"] = cmp.mapping.close(),
27+
["<Tab>"] = cmp.mapping(function(fallback)
28+
if cmp.visible() then
29+
cmp.select_next_item()
30+
elseif require('luasnip').expand_or_jumpable() then
31+
require('luasnip').expand_or_jump()
32+
elseif has_words_before() then
33+
cmp.complete()
34+
else
35+
fallback()
36+
end
37+
end, {"i", "s"}),
38+
["<S-Tab>"] = cmp.mapping(function(fallback)
39+
if cmp.visible() then
40+
cmp.select_prev_item()
41+
elseif require('luasnip').jumpable(-1) then
42+
require('luasnip').jump(-1)
43+
else
44+
fallback()
45+
end
46+
end, {"i", "s"})
47+
},
48+
snippet = {
49+
expand = function(args)
50+
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
51+
end
52+
},
53+
sources = {{name = 'nvim_lsp'}, {name = 'luasnip'}},
54+
completion = {completeopt = 'menu,menuone,noinsert'},
55+
experimental = {ghost_text = true}
56+
}
57+
58+
require("luasnip").config.set_config {history = true, updateevents = "TextChanged,TextChangedI"}
59+
require("luasnip.loaders.from_vscode").load()
60+
61+
require('nvim-autopairs').setup()
62+
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
63+
local cmp = require('cmp')
64+
65+
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({map_char = {tex = ''}}))
66+
67+
cmp_autopairs.lisp[#cmp_autopairs.lisp + 1] = "racket"
68+
69+
local capabilities = vim.lsp.protocol.make_client_capabilities()
70+
capabilities.textDocument.completion.completionItem.snippetSupport = true
71+
capabilities.textDocument.completion.completionItem.resolveSupport = {
72+
properties = {'documentation', 'detail', 'additionalTextEdits'}
73+
}
74+
75+
local sumneko_root_path = vim.fn.expand("$HOME") .. '/github/sumneko/lua-language-server'
76+
local sumneko_binary = vim.fn.expand("$HOME") .. '/github/sumneko/lua-language-server/bin/macOS/lua-language-server'
77+
78+
local lua_cfg = {
79+
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
80+
settings = {
81+
Lua = {
82+
runtime = {version = "LuaJIT", path = vim.split(package.path, ";")},
83+
diagnostics = {enable = true}
84+
}
85+
},
86+
capabilities = capabilities
87+
88+
}
89+
90+
local signature_config = {
91+
log_path = vim.fn.expand("$HOME") .. "/tmp/sig.log",
92+
debug = true,
93+
hint_enable = false,
94+
handler_opts = {border = "single"},
95+
max_width = 80
96+
}
97+
98+
require"lsp_signature".setup(signature_config)
99+
100+
require'lspconfig'.sumneko_lua.setup(lua_cfg)
101+
require'lspconfig'.gopls.setup {capabilities = capabilities}
102+
vim.cmd([[set mouse=a]])

min/sigmin.vim

+4-16
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ local nvim_lsp = require'lspconfig'
2323
local signature_config = {
2424
log_path = vim.fn.expand("$HOME") .. "/tmp/sig.log",
2525
debug = true,
26-
-- bind = true,
27-
-- hint_prefix = "",
28-
-- hi_parameter = "Search",
29-
-- fix_pos = true,
30-
-- extra_trigger_chars = {"(", ","},
31-
-- handler_opts = {
32-
-- border = "none",
33-
-- }
3426
hint_enable = false,
3527
handler_opts = {
3628
border = "single",
@@ -64,14 +56,11 @@ local lua_cfg = {
6456
settings = {
6557
Lua = {
6658
runtime = {
67-
-- Tell the language server which version of Lua you're -- using (most ely LuaJIT in the case of Neovim)
68-
version = "LuaJIT",
69-
-- Setup your lua path
59+
version = "LuaJIT",
7060
path = vim.split(package.path, ";")
7161
},
7262
diagnostics = {
7363
enable = true,
74-
-- Get the language server to recognize the `vim` global
7564
globals = {
7665
"vim",
7766
"describe",
@@ -83,7 +72,6 @@ local lua_cfg = {
8372
}
8473
},
8574
workspace = {
86-
-- Make the server aware of Neovim runtime files
8775
library = {
8876
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
8977
[vim.fn.expand("$VIMRUNTIME/lua/vim")] = true,
@@ -101,11 +89,11 @@ require "lsp_signature".setup(signature_config)
10189
require 'go'.setup({
10290
verbose = true,
10391
goimport = 'goimports',
104-
lsp_cfg =
92+
lsp_cfg =
10593
{settings={gopls={matcher='CaseInsensitive', ['local'] = "~/github/go", gofumpt = true }}}
106-
94+
10795
})
10896

10997
EOF
11098
set mouse=a
111-
colorscheme evening
99+
colorscheme evening

0 commit comments

Comments
 (0)