You've already forked dotfiles
feat: Replacement of the autopairs plugin using snippets, extension of
snippets (mainly python) and cleanup of keymappings for snippets.
This commit is contained in:
@@ -3,9 +3,9 @@ return {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
pycodestyle = {
|
||||
enabled = false,
|
||||
enabled = true,
|
||||
ignore = {
|
||||
'E501'
|
||||
'E501' -- line-too-long
|
||||
},
|
||||
maxLineLength = 120,
|
||||
},
|
||||
@@ -13,7 +13,6 @@ return {
|
||||
enabled = true,
|
||||
args = {
|
||||
'--disable=line-too-long',
|
||||
'--disable=missing-function-docstring'
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,11 @@ vim.schedule(function()
|
||||
require('plugins.render-markdown') -- Render markdown directly in neovim
|
||||
|
||||
vim.pack.add({
|
||||
'https://github.com/windwp/nvim-autopairs', -- Autocomplete symbol pairs when typing
|
||||
'https://github.com/tpope/vim-surround', -- Change surrounding characters (doesn't need setup called)
|
||||
'https://github.com/tpope/vim-fugitive', -- _The_ Git integration plugin people have been using forever
|
||||
'https://github.com/habamax/vim-godot' -- Godot specific bindings and debug
|
||||
})
|
||||
|
||||
require('nvim-autopairs').setup() -- Automatic pair completion of paranteticals, braces, quotes, etc.
|
||||
require('plugins.dap') -- DAP debugging plugin
|
||||
require('plugins.dap-python') -- Debug plugin settings specifically for python
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
vim.pack.add({
|
||||
-- 'https://github.com/saadparwaiz1/cmp_luasnip',
|
||||
'https://github.com/saadparwaiz1/cmp_luasnip',
|
||||
'https://github.com/rafamadriz/friendly-snippets',
|
||||
'https://github.com/L3MON4D3/LuaSnip'
|
||||
})
|
||||
@@ -18,7 +18,8 @@ local function luasnip_dependency_update()
|
||||
if out.code == 0 then
|
||||
vim.notify('LuaSnip jsregexp built successfully!', vim.log.levels.INFO)
|
||||
else
|
||||
vim.notify('Failed to build LuaSnip jsregexp:\n' .. (out.stderr or out.stdout or ''), vim.log.levels.ERROR)
|
||||
vim.notify('Failed to build LuaSnip jsregexp:\n' .. (out.stderr or out.stdout or ''),
|
||||
vim.log.levels.ERROR)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@@ -42,6 +43,6 @@ require('luasnip.loaders.from_vscode').lazy_load()
|
||||
require('luasnip.loaders.from_lua').lazy_load({ paths = "./snippets" })
|
||||
|
||||
-- TODO: Figure out keymappings that make sense
|
||||
vim.keymap.set({ 'i' }, '<C-k>', function() require('luasnip').expand() end, { silent = true })
|
||||
vim.keymap.set({ 'i', 's' }, '<C-l>', function() require('luasnip').jump(1) end, { silent = true })
|
||||
vim.keymap.set({ 'i', 's' }, '<C-j>', function() require('luasnip').jump(-1) end, { silent = true })
|
||||
vim.keymap.set({ 'i' }, '<C-K>', function() require('luasnip').expand() end, { silent = true })
|
||||
vim.keymap.set({ 'i', 's' }, '<C-L>', function() require('luasnip').jump(1) end, { silent = true })
|
||||
vim.keymap.set({ 'i', 's' }, '<C-H>', function() require('luasnip').jump(-1) end, { silent = true })
|
||||
|
||||
36
nvim/snippets/all.lua
Normal file
36
nvim/snippets/all.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
-- require('luasnip.session.snippet_collection').clear_snippets('all')
|
||||
|
||||
local ls = require('luasnip')
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local i = ls.insert_node
|
||||
local t = ls.text_node
|
||||
local c = ls.choice_node
|
||||
local r = ls.restore_node
|
||||
|
||||
-- Replacement of autopairs
|
||||
local function pair(pair_begin, pair_end)
|
||||
-- Auto-pair using snippets
|
||||
return s({ trig = pair_begin, wordTrig = false }, {
|
||||
t({ pair_begin }),
|
||||
c(1, {
|
||||
r(1, "content", i(1)),
|
||||
sn(nil, { t({"", "\t"}), r(1, "content", i(1)), t({ "", "" }) }),
|
||||
}),
|
||||
t({ pair_end }),
|
||||
})
|
||||
end
|
||||
|
||||
ls.add_snippets('all', {
|
||||
pair('(', ')'),
|
||||
pair('{', '}'),
|
||||
pair('[', ']'),
|
||||
pair('<', '>'),
|
||||
pair("'", "'"),
|
||||
pair('"', '"'),
|
||||
pair('`', '`'),
|
||||
}, {
|
||||
type = 'autosnippets',
|
||||
key = 'all_auto',
|
||||
})
|
||||
-- end autopairs
|
||||
@@ -1,44 +1,36 @@
|
||||
local ls = require('luasnip')
|
||||
local s = ls.snippet
|
||||
-- local sn = ls.snippet_node
|
||||
local i = ls.insert_node
|
||||
local t = ls.text_node
|
||||
local l = require('luasnip.extras').lambda
|
||||
-- local l = require('luasnip.extras').lambda
|
||||
local fmt = require('luasnip.extras.fmt').fmt
|
||||
local ts_post = require('luasnip.extras.treesitter_postfix').treesitter_postfix
|
||||
-- local ts_post = require('luasnip.extras.treesitter_postfix').treesitter_postfix
|
||||
|
||||
return {
|
||||
ts_post({
|
||||
matchTSNode = {
|
||||
query = [[
|
||||
(function_definition
|
||||
parameters: (parameters) @params
|
||||
return_type: (type) @return
|
||||
) @prefix
|
||||
]],
|
||||
query_lang = "python",
|
||||
},
|
||||
trig = "docstring",
|
||||
}, fmt([[
|
||||
''' {}
|
||||
|
||||
Keyword arguments:
|
||||
{} () -
|
||||
|
||||
Return:
|
||||
{} - {}
|
||||
'''
|
||||
ls.add_snippets('python', {
|
||||
s('docstring single', {
|
||||
t("''' "), i(0, 'text'), t(" '''")
|
||||
}),
|
||||
s('def', fmt([[
|
||||
def {func}({args}) -> {ret}:
|
||||
''' {doc} '''
|
||||
{body}
|
||||
]], {
|
||||
i(1, 'Description'),
|
||||
l(l.LS_TSCAPTURE_PARAMS),
|
||||
l(l.LS_TSCAPTURE_RETURN),
|
||||
l(l.LS_TSDATA),
|
||||
func = i(1, 'fname'),
|
||||
args = i(2),
|
||||
ret = i(3, 'None'),
|
||||
doc = i(4, 'docstring'),
|
||||
body = i(5, 'pass'),
|
||||
}, {
|
||||
})),
|
||||
-- s(
|
||||
-- { trig = "thingy" },
|
||||
-- { t('Woot!') }
|
||||
-- ),
|
||||
-- s(
|
||||
-- { trig = 'thingy2' },
|
||||
-- { t('Woot2!') }
|
||||
-- )
|
||||
}
|
||||
s('ternary', {
|
||||
i(1, 'then'), t(' if '), i(2, 'condition'), t(' else '), i(3, 'else')
|
||||
}),
|
||||
s('tuple ternary', fmt([[
|
||||
({if_true}, {if_false})[{condition}]
|
||||
]], {
|
||||
if_true = i(1, 'if_true'),
|
||||
if_false = i(2, 'if_false'),
|
||||
condition = i(3, 'condition'),
|
||||
})),
|
||||
})
|
||||
|
||||
@@ -53,6 +53,8 @@ if wezterm.target_triple == 'x86_64-unknown-linux-gnu' then
|
||||
config.xcursor_theme = xcursor_theme
|
||||
config.xcursor_size = xcursor_size
|
||||
-- end cursor theme
|
||||
|
||||
config.disable_default_key_bindings = true
|
||||
end
|
||||
|
||||
local local_config_filename = os.getenv('HOME') .. '/.config/wezterm/local.lua'
|
||||
|
||||
Reference in New Issue
Block a user