diff --git a/.gitignore b/.gitignore index 005b535..af70669 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ nvim spell/ lazy-lock.json + +.pynvim diff --git a/init.lua b/init.lua index 7758df9..26115b3 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 and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -643,6 +643,46 @@ require('lazy').setup({ }, }, }, + + pylsp = { + plugins = { + pycodestyle = { enabled = false }, + pyflakes = { enabled = false }, + pyls_memestra = { enabled = true }, + mccabe = { enabled = false }, + rope = { enabled = true }, + pylsp_mypy = { + enabled = false, + live_mode = true, + dmypy = false, + report_progress = true, + }, + jedi_symbols = { enabled = true }, + jedi_hover = { enabled = true }, + jedi_references = { enabled = true }, + jedi_signature_help = { enabled = true }, + jedi_definition = { enabled = true }, + jedi_completion = { enabled = true }, + ruff = { + enabled = true, + formatEnabled = true, + extendSelect = { 'I' }, + extendIgnore = { 'C90' }, + format = { 'I' }, + severities = { + D212 = { 'I' }, + }, + unsageGixes = false, + lineLength = 88, + exclude = { '__about__.py' }, + select = { 'F' }, + ignore = { 'D210' }, + perFileIgnores = {}, + preview = false, + targetVersion = { 'py310' }, + }, + }, + }, } -- Ensure the servers and tools above are installed @@ -658,6 +698,9 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'markdownlint', + 'ruff', + 'pylsp', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -710,6 +753,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + python = { 'ruff' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -899,7 +943,7 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'go', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'python', 'query', 'vim', 'vimdoc' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -928,18 +972,18 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', + require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lua/custom/plugins/cmp.toggle.lua b/lua/custom/plugins/cmp.toggle.lua new file mode 100644 index 0000000..c6f9547 --- /dev/null +++ b/lua/custom/plugins/cmp.toggle.lua @@ -0,0 +1,14 @@ +return { + 'hrsh7th/nvim-cmp', + dependencies = { + -- ... + -- This allows you to enable and disable the autocomplete popup: + { + 'gitaarik/nvim-cmp-toggle', + config = function() + vim.api.nvim_set_keymap('n', 'tc', ':NvimCmpToggle', { desc = '[T]oggle [C]ompletions', noremap = true, silent = true }) + end, + }, + -- ... + }, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d..96d544d 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,41 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +-- local job_id = 0 + +return { + -- vim.opt_local.shiftwidth = 2 + -- vim.opt.clipboard = 'unnamedplus' + -- vim.opt_local.number = true + -- vim.opt_local.relativenummber = true + -- vim.g.python3_host_prog = vim.fs.joinpatth(vim.fn.stdpath('config'), '.pynvim/bin/python'), + vim.api.nvim_set_var('python3_host_prog', vim.fs.joinpath(vim.fn.stdpath 'config', '.pynvim/bin/python')), + + vim.keymap.set('n', 'rf', 'source %', { desc = '[R]eload [F]ile' }), + + -- Reload line + vim.keymap.set('n', 'x', ':.lua', { desc = '[R]eload [L]ine' }), + -- Reload selection + vim.keymap.set('v', 'x', 'lua', { desc = '[R]eload [L]ine' }), + + vim.keymap.set('n', 'x', ':.lua', { desc = 'Quickfix Next' }), + vim.keymap.set('n', 'x', ':.lua', { desc = 'Quickfix Prev' }), + + vim.api.nvim_create_autocmd('TermOpen', { + group = vim.api.nvim_create_augroup('custom-term-open', { clear = true }), + callback = function() + vim.opt.number = false + vim.opt.relativenumber = false + end, + }), + + -- local job)id = 0 + -- + -- vim.keymap.set('n', 'st', function() + -- vim.cmd.vnew() + -- vim.cmd.term() + -- vim.cmd.wincmd 'J' + -- vim.api.nvim_win_set_height(0, 5) + -- job_id = vim.bo.channel + -- end), +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 0000000..3fc0e27 --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,11 @@ +return { + { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + -- Optional dependencies + --dependencies = { { "echasnovski/mini.icons", opts = {} } }, + dependencies = { 'nvim-tree/nvim-web-devicons' }, -- use if prefer nvim-web-devicons + }, +} diff --git a/lua/custom/telescope/multigrep.lua b/lua/custom/telescope/multigrep.lua new file mode 100644 index 0000000..02da8fc --- /dev/null +++ b/lua/custom/telescope/multigrep.lua @@ -0,0 +1,53 @@ +local pickers = require "telescope.pickers" +local finders = require "telescope.finders" +local make_entry = require "telescope.make_entry" +local conf = require "telescope.config".values + +local M = {} + +local live_multigrep = function(opts) + opts = opts or {} + opts.cwd = opts.cwd or vim.uv.cwd() + + local finder = finders.new_async_job { + if not prompt or prompt == "" then + return nil + end + + local pieces = vim.split(prompt, " ") + local args = { "rg" } + if pieces[1] then + table.insert(args, "-e") + table.insert(arga, pieces[1]) + end + + if pieces[2] then + table.insert(args, "-e") + table.insert(arga, pieces[2]) + end + + ---@diagnostic disable-next-line: deprecated + return vim.tbl_flatten { + args, + { "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" }, + } + end, + entry_maker = make_entry.gen_from_wimgrep(opts), + cwd = opts.cwd, + } + + pickers.new(opts, { + debounce = 100, + prompt_title = "Multi Grep", + finder = finder, + previewer = conf.grep+_previewer(opts), + sorter = require("telescope.sorters").empty(), + }):find() +end + +M.setup = function() + -- vim.keymapset("n", "fg", live_multigrep) + vim.keymap.set('n', 'sm', live_multigrep, { desc = '[S]earch [M]ulti Grep' }) +end + +return M