This commit is contained in:
clint-mbp 2023-08-28 19:43:07 -05:00
parent d0a67da1e1
commit 9bb85c1faa
8 changed files with 150 additions and 136 deletions

View File

@ -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;
-- },
-- }

View File

@ -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', '<F5>', ":w<CR>:exec '!clear;python' shellescape(@%, 1)<CR>", default_ops)
-- Handy stuff
keymap('n', '<Leader>m', 'iif __name__ == "__main__":<Esc>o<Tab>main()<Esc>o<Bs><Bs><Esc>', default_ops)
keymap('n', '<Leader>m', 'iif __name__ == "__main__":<Esc>o main()<Esc>o<Bs><Bs><Esc>', default_ops)
-- keymap('n', '<Leader>f', 'idef ():<Esc>bi', default_ops)
-- Comment/Uncomment
keymap('n', '<Leader>\\', '0i# <Esc>', default_ops)
keymap('n', '<Leader>-', '0xx', default_ops)
keymap('v', '<Leader>\\', '<C-v>kI# <Esc>', default_ops)
keymap('v', '<Leader>-', '<C-v>klx<Esc>', default_ops)
-- Indenting
keymap('v', '<', '<gv', default_ops)
keymap('v', '>', '>gv', default_ops)
-- REPL
keymap('v', '<CR>', ':ToggleTermSendVisualLines 100<CR><CR>', 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', '<F1>', ":w<CR>:exec '!clear;python3' shellescape(@%, 1)<CR>", default_ops)
keymap('n', '<F1>', ":lua _exec_python_toggle()<CR>", 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', '<F2>', ":lua _ipython_toggle()<CR>", default_ops)
keymap('i', '<F2>', "<Esc>:lua _ipython_toggle()<CR><Cmd>wincmd k<CR>", default_ops)
keymap('t', '<F2>', "<Esc><Cmd>wincmd k<CR>:lua _ipython_toggle()<CR>", default_ops)
-- REPL to the ipython terminal
keymap('v', '<Leader>x', ':ToggleTermSendVisualLines 200<CR><CR><CR>', default_ops)
keymap('n', '<Leader>x', ':ToggleTermSendCurrentLine 200<CR><CR>', 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', '<F3>', ":lua _pytest_toggle()<CR>", default_ops)

View File

@ -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')

View File

@ -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;
-- },
-- }

View File

@ -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', '<Leader>o', ':SymbolsOutline<CR>', default_ops)
-- keymap('n', '<F7>', ":lua require'dap'.step_over()<CR>", default_ops)
-- keymap('n', '<Leader>D', ":lua require'dapui'.toggle()<CR>", default_ops)
-- REPL
keymap('v', '<Leader>x', ':ToggleTermSendVisualLines 100<CR><CR><CR>', default_ops)
keymap('n', '<Leader>x', ':ToggleTermSendCurrentLine 100<CR><CR>', 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', '<F1>', ":lua _ipython_toggle()<CR>", default_ops)
keymap('i', '<F1>', "<Esc>:lua _ipython_toggle()<CR><Cmd>wincmd k<CR>", default_ops)
keymap('t', '<F1>', "<Esc><Cmd>wincmd k<CR>:lua _ipython_toggle()<CR>", 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', '<F12>', ":lua _pytest_toggle()<CR>", default_ops)

View File

@ -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 },
-- }

View File

@ -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',
},
}

View File

@ -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
{