diff --git a/init.lua b/init.lua index 506bbaf5..c38c1189 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, for help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -162,8 +162,12 @@ vim.opt.hlsearch = true vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) +vim.keymap.set('n', '[d', function() + vim.diagnostic.goto_prev { float = { source = true } } +end, { desc = 'Go to previous [D]iagnostic message' }) +vim.keymap.set('n', ']d', function() + vim.diagnostic.goto_next { float = { source = true } } +end, { desc = 'Go to next [D]iagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) @@ -320,6 +324,7 @@ require('lazy').setup({ -- Useful for getting pretty icons, but requires a Nerd Font. { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + { 'smartpde/telescope-recent-files' }, }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -375,7 +380,8 @@ require('lazy').setup({ vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + -- vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '', "lua require('telescope').extensions.recent_files.pick()", { desc = '[ ] Recent files' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() @@ -542,6 +548,21 @@ require('lazy').setup({ -- clangd = {}, -- gopls = {}, -- pyright = {}, + pylsp = { + settings = { + pylsp = { + configurationSources = { 'flake8' }, + plugins = { + mypy = { enabled = true }, + black = { enabled = true }, + flake8 = { enabled = true }, + pycodestyle = { enabled = false }, + rope_autoimport = { enabled = true }, + rope_completion = { enabled = true }, + }, + }, + }, + }, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -576,6 +597,34 @@ require('lazy').setup({ -- You can press `g?` for help in this menu require('mason').setup() + -- PyLSP config: install additional plugins + local pylsp = require('mason-registry').get_package 'python-lsp-server' + pylsp:on('install:success', function() + local function mason_package_path(package) + local path = vim.fn.resolve(vim.fn.stdpath 'data' .. '/mason/packages/' .. package) + return path + end + + local path = mason_package_path 'python-lsp-server' + local command = path .. '/venv/bin/pip' + local args = { + 'install', + 'pylsp-rope', + 'python-lsp-black', + 'pyflakes', + 'python-lsp-ruff', + 'sqlalchemy-stubs', + } + + require('plenary.job') + :new({ + command = command, + args = args, + cwd = path, + }) + :start() + end) + -- You can add other tools here that you want Mason to install -- for you, so that they are available from within Neovim. local ensure_installed = vim.tbl_keys(servers or {}) @@ -616,7 +665,7 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { 'isort', 'black' }, -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. @@ -837,7 +886,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you have a Nerd Font, set icons to an empty table which will use the diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..63079339 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,184 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { + 'christoomey/vim-tmux-navigator', + cmd = { + 'TmuxNavigateLeft', + 'TmuxNavigateDown', + 'TmuxNavigateUp', + 'TmuxNavigateRight', + 'TmuxNavigatePrevious', + }, + keys = { + -- there were come ctrl+hjkl stuff here but i don't think i need it, use alt+arrows + }, + }, + { + 'nvim-tree/nvim-tree.lua', + version = '*', + lazy = false, + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = function() + require('nvim-tree').setup { + vim.keymap.set('n', 'tt', ':NvimTreeToggle\n', { desc = '[T]oggle NVim[T]ree' }), + } + end, + }, + { + 'nvimtools/none-ls.nvim', + ft = { 'python' }, + opts = function() + local null_ls = require 'null-ls' + return { + sources = { + null_ls.builtins.diagnostics.mypy.with { + extra_args = function() + local virtual = os.getenv 'VIRTUAL_ENV' or os.getenv 'CONDA_PREFIX' or '/usr' + return { '--python-executable', virtual .. '/bin/python3' } + end, + }, + null_ls.builtins.formatting.isort.with { prefer_local = true }, + }, + } + end, + }, + { + 'mfussenegger/nvim-dap', + config = function() + vim.keymap.set('n', 'db', ' DapToggleBreakpoint ', { desc = '[D]ebug [B]reakpoint' }) + vim.keymap.set('n', '', function() + require('dap').continue() + end, { desc = 'Step Over' }) + vim.keymap.set('n', '', function() + require('dap').step_over() + end, { desc = 'Step Over' }) + vim.keymap.set('n', '', function() + require('dap').step_into() + end, { desc = 'Step Into' }) + end, + }, + { + 'mfussenegger/nvim-dap-python', + ft = 'python', + dependencies = { + 'mfussenegger/nvim-dap', + }, + config = function() + local path = '~/.local/share/nvim/mason/packages/debugpy/venv/bin/python' + require('dap-python').setup(path) + end, + }, + { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-neotest/nvim-nio', + 'nvim-lua/plenary.nvim', + 'antoinemadec/FixCursorHold.nvim', + 'nvim-treesitter/nvim-treesitter', + 'nvim-neotest/neotest-python', + }, + config = function() + require('neotest').setup { + adapters = { + require 'neotest-python' { + dap = { justMyCode = false }, + pytest_discover_instances = true, + }, + }, + } + vim.keymap.set('n', 'tn', function() + require('neotest').run.run() + end, { desc = '[T]ests: Run [N]earest' }) + vim.keymap.set('n', 'tdn', function() + require('neotest').run.run { strategy = 'dap' } + end, { desc = '[T]ests: [D]ebug [N]earest' }) + vim.keymap.set('n', 'tf', function() + require('neotest').run.run(vim.fn.expand '%') + end, { desc = '[T]ests: Run all tests in [F]ile' }) + vim.keymap.set('n', 'to', function() + require('neotest').output.open { enter = true } + end, { desc = '[T]ests: Open [O]utput Window' }) + end, + }, + { + 'rcarriga/nvim-dap-ui', + dependencies = { 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' }, + config = function() + local dap, dapui = require 'dap', require 'dapui' + dap.listeners.before.attach.dapui_config = function() + dapui.setup() + dapui.open() + end + dap.listeners.before.launch.dapui_config = function() + dapui.setup() + dapui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + dapui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + dapui.close() + end + end, + }, + { + 'folke/neodev.nvim', + opts = {}, + config = function() + require('neodev').setup { + library = { plugins = { 'nvim-dap-ui' }, types = true }, + } + end, + }, + { + 'tpope/vim-fugitive', + config = function() + vim.keymap.set('n', 'gb', 'Telescope git_branches', { desc = '[G]it [B]ranches' }) + vim.keymap.set('n', 'gs', 'Git', { desc = '[G]it [S]tatus' }) + vim.keymap.set('n', 'gc', function() + local ok, _ = pcall(vim.cmd, 'G commit -a') + if ok then + local branch = vim.fn.system "git branch --show-current | tr -d '\n'" + local ticket = branch:match '([A-Z]+%-%d+)' + vim.cmd 'startinsert' + vim.api.nvim_put({ string.format('feat(%s): ', ticket) }, 'c', true, true) + end + end, { desc = '[G]it [C]ommit' }) + vim.keymap.set('n', 'gp', 'Git push', { desc = '[G]it [P]ush' }) + vim.keymap.set('n', 'gf', 'Git pull', { desc = '[G]it [F]pull' }) + end, + }, + { + 'github/copilot.vim', + }, + { + 'nvimdev/dashboard-nvim', + event = 'VimEnter', + config = function() + require('dashboard').setup { + config = { + header = { + '⠀⢀⣴⣦⠀⠀⠀⠀⢰⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀', + '⣰⣿⣿⣿⣷⡀⠀⠀⢸⣿⣷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀', + '⣿⣿⣿⣿⣿⣿⣄⠀⢸⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀', + '⣿⣿⣿⠈⢿⣿⣿⣦⢸⣿⣿⡇⠀⣠⠴⠒⠢⣄⠀⠀⣠⠴⠲⠦⣄⠐⣶⣆⠀⠀⢀⣶⡖⢰⣶⠀⢰⣶⣴⡶⣶⣆⣴⡶⣶⣶⡄', + '⣿⣿⣿⠀⠀⠻⣿⣿⣿⣿⣿⡇⢸⣁⣀⣀⣀⣘⡆⣼⠁⠀⠀⠀⠘⡇⠹⣿⡄⠀⣼⡿⠀⢸⣿⠀⢸⣿⠁⠀⢸⣿⡏⠀⠀⣿⣿', + '⠹⣿⣿⠀⠀⠀⠙⣿⣿⣿⡿⠃⢸⡀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⢀⡏⠀⢻⣿⣸⣿⠁⠀⢸⣿⠀⢸⣿⠀⠀⢸⣿⡇⠀⠀⣿⣿', + '⠀⠈⠻⠀⠀⠀⠀⠈⠿⠋⠀⠀⠈⠳⢤⣀⣠⠴⠀⠈⠧⣄⣀⡠⠞⠁⠀⠀⠿⠿⠃⠀⠀⢸⣿⠀⢸⣿⠀⠀⠸⣿⡇⠀⠀⣿⡿', + }, + shortcut = {}, + footer = { + ' ', + ' 👾 github.com/feakuru 👾 ', + }, + }, + hide = { statusline = false, tabline = false, winbar = false }, + } + end, + dependencies = { { 'nvim-tree/nvim-web-devicons' } }, + }, +}