diff --git a/nvim/after/lsp/pylsp.lua b/nvim/after/lsp/pylsp.lua index 0bf57fe..fee203d 100644 --- a/nvim/after/lsp/pylsp.lua +++ b/nvim/after/lsp/pylsp.lua @@ -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' }, } } diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index d3cfc45..f17bf4f 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -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 diff --git a/nvim/lua/plugins/luasnip.lua b/nvim/lua/plugins/luasnip.lua index 0ddffca..731d01f 100644 --- a/nvim/lua/plugins/luasnip.lua +++ b/nvim/lua/plugins/luasnip.lua @@ -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' }, '', function() require('luasnip').expand() end, { silent = true }) -vim.keymap.set({ 'i', 's' }, '', function() require('luasnip').jump(1) end, { silent = true }) -vim.keymap.set({ 'i', 's' }, '', function() require('luasnip').jump(-1) end, { silent = true }) +vim.keymap.set({ 'i' }, '', function() require('luasnip').expand() end, { silent = true }) +vim.keymap.set({ 'i', 's' }, '', function() require('luasnip').jump(1) end, { silent = true }) +vim.keymap.set({ 'i', 's' }, '', function() require('luasnip').jump(-1) end, { silent = true }) diff --git a/nvim/snippets/all.lua b/nvim/snippets/all.lua new file mode 100644 index 0000000..96e91b6 --- /dev/null +++ b/nvim/snippets/all.lua @@ -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 diff --git a/nvim/snippets/python.lua b/nvim/snippets/python.lua index 6bbd1ba..fca7d2e 100644 --- a/nvim/snippets/python.lua +++ b/nvim/snippets/python.lua @@ -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'), + })), +}) diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua index 2a4a2e5..b063a81 100644 --- a/wezterm/wezterm.lua +++ b/wezterm/wezterm.lua @@ -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'