diff --git a/init.lua b/init.lua index d5ae6dc9b2a..e7b13638b71 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.o` @@ -197,11 +197,13 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn -- or just use to exit terminal mode vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) +vim.keymap.set('i', 'kj', '', { noremap = true, silent = true }) + -- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows @@ -593,10 +595,71 @@ require('lazy').setup({ -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- See `:help lsp-config` for information about keys and how to configure local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + clangd = {}, + gopls = {}, + -- pyright = {}, -- too heavy and slow :< + rust_analyzer = {}, + + -- pylsp with ruff ext is real GOAT :> + pylsp = { + cmd = { 'pylsp', '-vvv', '--log-file', '/tmp/lsp.log' }, + settings = { + pylsp = { + plugins = { + -- Quite useful + rope_autoimport = { + enabled = true, + completions = { + enabled = false, + }, + code_actions = { + enabled = true, + }, + }, + + -- Plugin conflict resolving for pylsp_rope plugin + rope_rename = { + enabled = false, -- using pylsp_rope's rename instead + }, + jedi_rename = { + enabled = false, -- using pylsp_rope's rename instead + }, + + -- Advanced impl of renaming using rope + pylsp_rope = { + enabled = true, + rename = true, + }, + ruff = { + enabled = true, -- Enable the plugin + formatEnabled = true, -- Enable formatting using ruffs formatter + -- executable = '~/.rye/tools/ruff/bin/ruff', -- Custom path to ruff + -- config = '~/.rye/tools/ruff/bin/.pylsp_ruff_custom_global.toml', -- Custom config for ruff to use + extendSelect = { 'I' }, -- Rules that are additionally used by ruff + extendIgnore = { 'C90' }, -- Rules that are additionally ignored by ruff + format = { 'I' }, -- Rules that are marked as fixable by ruff that should be fixed when running textDocument/formatting + severities = { ['D212'] = 'I' }, -- Optional table of rules where a custom severity is desired + unsafeFixes = false, -- Whether or not to offer unsafe fixes as code actions. Ignored with the "Fix All" action + + -- -- Rules that are ignored when a pyproject.toml or ruff.toml is present: + -- lineLength = 88, -- Line length to pass to ruff checking and formatting + -- exclude = { '__about__.py' }, -- Files to be excluded by ruff checking + -- select = { 'F' }, -- Rules to be enabled by ruff + -- ignore = { 'D210' }, -- Rules to be ignored by ruff + perFileIgnores = { ['__init__.py'] = 'CPY001' }, -- Rules that should be ignored for specific files + preview = true, -- Whether to enable the preview style linting and formatting. + -- targetVersion = 'py310', -- The minimum python version to target (applies for both linting and formatting). + }, + + pylsp_mypy = { + enabled = true, + exclude = { 'tests/*', 'leetcode/*' }, + }, + }, + }, + }, + }, + -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim @@ -616,7 +679,11 @@ require('lazy').setup({ vim.list_extend(ensure_installed, { 'lua_ls', -- Lua Language server 'stylua', -- Used to format Lua code - -- You can add other tools here that you want Mason to install + 'prettierd', -- formatter + 'delve', -- Golang DAP debugger + 'markdownlint-cli2', + 'npm-groovy-lint', + 'vale', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -846,6 +913,11 @@ require('lazy').setup({ -- ... and there is more! -- Check out: https://github.com/nvim-mini/mini.nvim + + -- Lyu: activate mini.animate + if not vim.g.neovide then + require('mini.animate').setup() + end end, }, @@ -870,18 +942,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.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + 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! @@ -909,5 +981,12 @@ require('lazy').setup({ }, }) +-- ADDED Manually by Lyu +---- python provider set to pyenv venv interpreter 20240927 +vim.g.python3_host_prog = '~/.rye/tools/pynvim/bin/python3' +-- avante.nvim: views can only be fully collapsed with the global statusline +vim.opt.laststatus = 3 +-- END ADDED Manually + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/avante.lua b/lua/custom/plugins/avante.lua new file mode 100644 index 00000000000..b1f3a9bdbc6 --- /dev/null +++ b/lua/custom/plugins/avante.lua @@ -0,0 +1,56 @@ +return { + 'yetone/avante.nvim', + event = 'VeryLazy', + lazy = false, + version = false, -- set this if you want to always pull the latest change + opts = { + -- add any opts here + -- Lyu + provider = 'openai', + openai = { + endpoint = 'https://aihubmix.com/v1', + model = 'claude-3-5-haiku-20241022', + temperature = 0, + max_tokens = 4096, + api_key_name = 'cmd:security find-generic-password -a avante.nvim -s anthropic-api-key -w', -- the shell command must prefixed with `^cmd:(.*)` + }, + }, + + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = 'make', + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + --- The below dependencies are optional, + 'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons + 'zbirenbaum/copilot.lua', -- for providers='copilot' + { + -- support for image pasting + 'HakonHarnes/img-clip.nvim', + event = 'VeryLazy', + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { 'markdown', 'Avante' }, + }, + ft = { 'markdown', 'Avante' }, + }, + }, +} diff --git a/lua/custom/plugins/leetcode.lua b/lua/custom/plugins/leetcode.lua new file mode 100644 index 00000000000..39a3bf45934 --- /dev/null +++ b/lua/custom/plugins/leetcode.lua @@ -0,0 +1,27 @@ +local leet_arg = 'leetcode.nvim' + +return { + 'kawre/leetcode.nvim', + build = ':TSUpdate html', + dependencies = { + 'nvim-telescope/telescope.nvim', + 'nvim-lua/plenary.nvim', -- required by telescope + 'MunifTanjim/nui.nvim', + + -- optional + 'nvim-treesitter/nvim-treesitter', + 'rcarriga/nvim-notify', + 'nvim-tree/nvim-web-devicons', + }, + lazy = leet_arg ~= vim.fn.argv()[1], + opts = { + -- configuration goes here + opts = { arg = leet_arg }, + lang = 'python3', + -- injector = { + -- ['python3'] = { + -- before = true, + -- }, + -- }, + }, +}