From 9bb85c1faa0b7a27793e14f1f591d0c1b66a3433 Mon Sep 17 00:00:00 2001 From: clint-mbp Date: Mon, 28 Aug 2023 19:43:07 -0500 Subject: [PATCH] cleanup --- nvim/.config/nvim/after/plugin/dap.lua | 52 ++++++++-------- nvim/.config/nvim/ftplugin/python.lua | 66 +++++++++++++++----- nvim/.config/nvim/init.lua | 2 +- nvim/.config/nvim/lua/clint/dap.lua | 68 ++++++++++----------- nvim/.config/nvim/lua/clint/keybindings.lua | 34 +---------- nvim/.config/nvim/lua/plugins/debug.lua | 13 ++-- nvim/.config/nvim/lua/plugins/init.lua | 37 ++++++----- nvim/.config/nvim/lua/plugins/util.lua | 14 ++--- 8 files changed, 150 insertions(+), 136 deletions(-) diff --git a/nvim/.config/nvim/after/plugin/dap.lua b/nvim/.config/nvim/after/plugin/dap.lua index f1dce8f..d002cae 100644 --- a/nvim/.config/nvim/after/plugin/dap.lua +++ b/nvim/.config/nvim/after/plugin/dap.lua @@ -1,26 +1,26 @@ -local dap = require('dap') -dap.configurations.python = { - { - -- The first three options are required by nvim-dap - type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python` - request = 'launch'; - name = "Launch file"; - - -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options - - program = "${file}"; -- This configuration will launch the current file if used. - pythonPath = function() - -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. - -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. - -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. - local cwd = vim.fn.getcwd() - if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then - return cwd .. '/venv/bin/python' - elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then - return cwd .. '/.venv/bin/python' - else - return '/usr/bin/python' - end - end; - }, -} +-- local dap = require('dap') +-- dap.configurations.python = { +-- { +-- -- The first three options are required by nvim-dap +-- type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python` +-- request = 'launch'; +-- name = "Launch file"; +-- +-- -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options +-- +-- program = "${file}"; -- This configuration will launch the current file if used. +-- pythonPath = function() +-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. +-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. +-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. +-- local cwd = vim.fn.getcwd() +-- if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then +-- return cwd .. '/venv/bin/python' +-- elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then +-- return cwd .. '/.venv/bin/python' +-- else +-- return '/usr/bin/python' +-- end +-- end; +-- }, +-- } diff --git a/nvim/.config/nvim/ftplugin/python.lua b/nvim/.config/nvim/ftplugin/python.lua index 7669969..fb331b1 100644 --- a/nvim/.config/nvim/ftplugin/python.lua +++ b/nvim/.config/nvim/ftplugin/python.lua @@ -2,28 +2,64 @@ local keymap = vim.api.nvim_set_keymap local default_ops = { noremap = true, silent = true } local settings = vim.opt -vim.g.mapleader = '\\' - --- Set up +-- PEP8 column settings.colorcolumn = "80" --- Execute file -keymap('n', '', ":w:exec '!clear;python' shellescape(@%, 1)", default_ops) - -- Handy stuff -keymap('n', 'm', 'iif __name__ == "__main__":omain()o', default_ops) +keymap('n', 'm', 'iif __name__ == "__main__":o main()o', default_ops) -- keymap('n', 'f', 'idef ():bi', default_ops) --- Comment/Uncomment -keymap('n', '\\', '0i# ', default_ops) -keymap('n', '-', '0xx', default_ops) -keymap('v', '\\', 'kI# ', default_ops) -keymap('v', '-', 'klx', default_ops) - -- Indenting keymap('v', '<', '', '>gv', default_ops) --- REPL -keymap('v', '', ':ToggleTermSendVisualLines 100', default_ops) +-- [[ F1 - Execute current file ]] +-- Execute file +local Terminal = require('toggleterm.terminal').Terminal +local exec_python = Terminal:new({ + cmd = "echo %", + direction = "float", + count = 100, + float_opts = { border = "curved" }, + close_on_exit = false +}) +function _exec_python_toggle() + exec_python:toggle() +end +-- keymap('n', '', ":w:exec '!clear;python3' shellescape(@%, 1)", default_ops) +keymap('n', '', ":lua _exec_python_toggle()", default_ops) + +-- [[ F2 - iPython Terminal ]] +-- Toggle a custom Terminal with ipython +local ipython = Terminal:new({ + cmd = "ipython", + direction = "horizontal", + count = 200 +}) +function _ipython_toggle() + ipython:toggle() +end + +keymap('n', '', ":lua _ipython_toggle()", default_ops) +keymap('i', '', ":lua _ipython_toggle()wincmd k", default_ops) +keymap('t', '', "wincmd k:lua _ipython_toggle()", default_ops) + +-- REPL to the ipython terminal +keymap('v', 'x', ':ToggleTermSendVisualLines 200', default_ops) +keymap('n', 'x', ':ToggleTermSendCurrentLine 200', default_ops) + +-- [[ F3 - Run Pytest ]] +-- Pytest +local pytest = Terminal:new({ + cmd = "python -m pytest", + direction = "float", + count = 300, + float_opts = { border = "curved" }, + close_on_exit = false +}) +function _pytest_toggle() + pytest:toggle() +end + +keymap('n', '', ":lua _pytest_toggle()", default_ops) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 06939c5..c8c327b 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -15,4 +15,4 @@ require("lazy").setup( ) -- loads each lua/plugin/* vim.cmd 'hi Normal guibg=NONE ctermbg=NONE' require("clint") -- loads lua/clint/init.lua -require('dap-python').setup('~/.virtualenvs/debugpy/bin/python') +-- require('dap-python').setup('~/.virtualenvs/debugpy/bin/python') diff --git a/nvim/.config/nvim/lua/clint/dap.lua b/nvim/.config/nvim/lua/clint/dap.lua index bedde6d..42168d9 100644 --- a/nvim/.config/nvim/lua/clint/dap.lua +++ b/nvim/.config/nvim/lua/clint/dap.lua @@ -1,34 +1,34 @@ -local dap = require('dap') -dap.adapters.python = { - type = 'executable'; - command = '~/.virtualenvs/debugpy/bin/python'; - args = { '-m', 'debugpy.adapter' }; -} - - -local dap = require('dap') -dap.configurations.python = { - { - -- The first three options are required by nvim-dap - type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python` - request = 'launch'; - name = "Launch file"; - - -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options - - program = "${file}"; -- This configuration will launch the current file if used. - pythonPath = function() - -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. - -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. - -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. - local cwd = vim.fn.getcwd() - if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then - return cwd .. '/venv/bin/python' - elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then - return cwd .. '/.venv/bin/python' - else - return 'python3' - end - end; - }, -} +-- local dap = require('dap') +-- dap.adapters.python = { +-- type = 'executable'; +-- command = '~/.virtualenvs/debugpy/bin/python'; +-- args = { '-m', 'debugpy.adapter' }; +-- } +-- +-- +-- local dap = require('dap') +-- dap.configurations.python = { +-- { +-- -- The first three options are required by nvim-dap +-- type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python` +-- request = 'launch'; +-- name = "Launch file"; +-- +-- -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options +-- +-- program = "${file}"; -- This configuration will launch the current file if used. +-- pythonPath = function() +-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself. +-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within. +-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable. +-- local cwd = vim.fn.getcwd() +-- if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then +-- return cwd .. '/venv/bin/python' +-- elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then +-- return cwd .. '/.venv/bin/python' +-- else +-- return 'python3' +-- end +-- end; +-- }, +-- } diff --git a/nvim/.config/nvim/lua/clint/keybindings.lua b/nvim/.config/nvim/lua/clint/keybindings.lua index f151209..a15fdf7 100644 --- a/nvim/.config/nvim/lua/clint/keybindings.lua +++ b/nvim/.config/nvim/lua/clint/keybindings.lua @@ -1,5 +1,5 @@ --[[ --- Generic Keybindings for all files +-- Generic Keybindings for all file types --]] local keymap = vim.api.nvim_set_keymap @@ -88,11 +88,6 @@ keymap('n', 'o', ':SymbolsOutline', default_ops) -- keymap('n', '', ":lua require'dap'.step_over()", default_ops) -- keymap('n', 'D', ":lua require'dapui'.toggle()", default_ops) --- REPL -keymap('v', 'x', ':ToggleTermSendVisualLines 100', default_ops) -keymap('n', 'x', ':ToggleTermSendCurrentLine 100', default_ops) - - -- Helpful stuff for ToggleTerm, taken from their docs function _G.set_terminal_keymaps() local opts = { buffer = 0 } @@ -108,31 +103,4 @@ end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') --- Toggle a custom Terminal with ipython -local Terminal = require('toggleterm.terminal').Terminal -local ipython = Terminal:new({ - cmd = "ipython", - direction = "horizontal", - count = 100 }) -function _ipython_toggle() - ipython:toggle() -end -keymap('n', '', ":lua _ipython_toggle()", default_ops) -keymap('i', '', ":lua _ipython_toggle()wincmd k", default_ops) -keymap('t', '', "wincmd k:lua _ipython_toggle()", default_ops) - --- Pytest -local Terminal = require('toggleterm.terminal').Terminal -local pytest = Terminal:new({ - cmd = "python -m pytest", - direction = "float", - count = 200, - float_opts = { border = "curved" }, - close_on_exit = false -}) -function _pytest_toggle() - pytest:toggle() -end - -keymap('n', '', ":lua _pytest_toggle()", default_ops) diff --git a/nvim/.config/nvim/lua/plugins/debug.lua b/nvim/.config/nvim/lua/plugins/debug.lua index 3f9a1db..df73ac9 100644 --- a/nvim/.config/nvim/lua/plugins/debug.lua +++ b/nvim/.config/nvim/lua/plugins/debug.lua @@ -1,6 +1,7 @@ -return { - { 'mfussenegger/nvim-dap' }, - { 'rcarriga/nvim-dap-ui', config = true }, - { "mfussenegger/nvim-dap-python" }, - { "theHamsta/nvim-dap-virtual-text", config = true }, -} +return {} +-- return { +-- { 'mfussenegger/nvim-dap' }, +-- { 'rcarriga/nvim-dap-ui', config = true }, +-- { "mfussenegger/nvim-dap-python" }, +-- { "theHamsta/nvim-dap-virtual-text", config = true }, +-- } diff --git a/nvim/.config/nvim/lua/plugins/init.lua b/nvim/.config/nvim/lua/plugins/init.lua index 6e318e0..f96b5ed 100644 --- a/nvim/.config/nvim/lua/plugins/init.lua +++ b/nvim/.config/nvim/lua/plugins/init.lua @@ -28,26 +28,25 @@ return { }, -- Debugging - { 'mfussenegger/nvim-dap' }, - { 'rcarriga/nvim-dap-ui', config = true }, - { "mfussenegger/nvim-dap-python" }, - { "theHamsta/nvim-dap-virtual-text", config = true }, + -- { 'mfussenegger/nvim-dap' }, + -- { 'rcarriga/nvim-dap-ui', config = true }, + -- { "mfussenegger/nvim-dap-python" }, + -- { "theHamsta/nvim-dap-virtual-text", config = true }, -------------------- -- Color schemes -------------------- - { "glepnir/oceanic-material" }, - { "savq/melange-nvim" }, + -- { "glepnir/oceanic-material" }, + -- { "savq/melange-nvim" }, { 'ayu-theme/ayu-vim' }, - -- { 'morhetz/gruvbox' }, - { 'ellisonleao/gruvbox.nvim' }, - { 'jacoborus/tender.vim' }, - { 'jpo/vim-railscasts-theme' }, - { 'rainux/vim-desert-warm-256' }, - { 'ajmwagar/vim-deus' }, - { "rebelot/kanagawa.nvim" }, - { "folke/tokyonight.nvim" }, + -- { 'ellisonleao/gruvbox.nvim' }, + -- { 'jacoborus/tender.vim' }, + -- { 'jpo/vim-railscasts-theme' }, + -- { 'rainux/vim-desert-warm-256' }, + -- { 'ajmwagar/vim-deus' }, + -- { "rebelot/kanagawa.nvim" }, + -- { "folke/tokyonight.nvim" }, -------------------- -- Utility @@ -190,4 +189,14 @@ return { -- Scroll bar -- { 'petertriho/nvim-scrollbar', config = true }, + + -- Start up time + { + 'dstein64/vim-startuptime', + }, + + -- maybe this helps startup + { + 'nathom/filetype.nvim', + }, } diff --git a/nvim/.config/nvim/lua/plugins/util.lua b/nvim/.config/nvim/lua/plugins/util.lua index c20aa69..080960a 100644 --- a/nvim/.config/nvim/lua/plugins/util.lua +++ b/nvim/.config/nvim/lua/plugins/util.lua @@ -100,13 +100,13 @@ return { }, }, - -- Object Explorer - { - 'simrat39/symbols-outline.nvim', - config = { - auto_preview = true, - } - }, + -- -- Object Explorer + -- { + -- 'simrat39/symbols-outline.nvim', + -- config = { + -- auto_preview = true, + -- } + -- }, -- Terminal {