diff --git a/init.lua b/init.lua index b98ffc6198a..1362e3800ee 100644 --- a/init.lua +++ b/init.lua @@ -19,7 +19,6 @@ ======== ======== ===================================================================== ===================================================================== - What is Kickstart? Kickstart.nvim is *not* a distribution. @@ -89,7 +88,6 @@ P.S. You can delete this when you're done too. It's your config now! :) -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) 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 @@ -102,7 +100,7 @@ vim.g.have_nerd_font = false vim.o.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.o.relativenumber = true +vim.o.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.o.mouse = 'a' @@ -159,7 +157,7 @@ vim.o.inccommand = 'split' vim.o.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. -vim.o.scrolloff = 10 +vim.o.scrolloff = 20 -- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), -- instead raise a dialog asking if you wish to save the current file(s) @@ -185,10 +183,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- 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 @@ -205,6 +203,12 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +vim.keymap.set('n', '', ':Explore', { desc = 'Open file manager' }) + +-- Support for russian keyboard layout in normal mode +vim.o.langmap = + 'ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz' + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -247,7 +251,7 @@ rtp:prepend(lazypath) -- NOTE: Here is where you install your plugins. require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - 'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically + { 'NMAC427/guess-indent.nvim', opts = {} }, -- Detect tabstop and shiftwidth automatically -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -412,7 +416,14 @@ require('lazy').setup({ -- i = { [''] = 'to_fuzzy_refine' }, -- }, -- }, - -- pickers = {} + pickers = { + find_files = { + hidden = true, + file_ignore_patterns = { '%.git/' }, + no_ignore = true, + no_ignore_parent = true, + }, + }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown(), @@ -472,6 +483,7 @@ require('lazy').setup({ library = { -- Load luvit types when the `vim.uv` word is found { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + vim.fn.expand '~/.luarocks/share/lua/5.3/', }, }, }, @@ -672,8 +684,13 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, - -- pyright = {}, + gopls = {}, + tofu_ls = {}, + marksman = {}, + bashls = {}, + jsonls = {}, + yamlls = {}, + ruff = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -720,7 +737,15 @@ require('lazy').setup({ require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { - ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) + ensure_installed = { + 'gopls', + 'yamlls', + 'jsonls', + 'solargraph', + 'bashls', + 'lua_ls', + 'ruff', + }, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) automatic_installation = false, handlers = { function(server_name) @@ -768,6 +793,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + go = { 'gofmt' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -799,12 +825,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, opts = {}, }, @@ -851,12 +877,23 @@ require('lazy').setup({ -- By default, you may press `` to show the documentation. -- Optionally, set `auto_show = true` to show the documentation after a delay. documentation = { auto_show = false, auto_show_delay_ms = 500 }, + -- Recommended to avoid unnecessary request + trigger = { prefetch_on_insert = false }, }, sources = { default = { 'lsp', 'path', 'snippets', 'lazydev' }, providers = { lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + -- minuet = { + -- name = 'minuet', + -- -- module = 'minuet.blink', + -- -- async = true, + -- -- -- Should match minuet.config.request_timeout * 1000, + -- -- -- since minuet.config.request_timeout is in seconds + -- timeout_ms = 3000, + -- score_offset = 50, -- Gives minuet higher priority among suggestions + -- }, }, }, @@ -944,7 +981,23 @@ 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', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'go', + 'yaml', + 'json', + 'python', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -973,9 +1026,9 @@ 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 @@ -984,7 +1037,7 @@ require('lazy').setup({ -- 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/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000000..1e80eb48726 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,7 @@ +return { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function +} diff --git a/lua/custom/plugins/cheatsheet.lua b/lua/custom/plugins/cheatsheet.lua new file mode 100644 index 00000000000..28b0df2acbf --- /dev/null +++ b/lua/custom/plugins/cheatsheet.lua @@ -0,0 +1,13 @@ +return { + 'sudormrfbin/cheatsheet.nvim', + + requires = { + { 'nvim-telescope/telescope.nvim' }, + { 'nvim-lua/popup.nvim' }, + { 'nvim-lua/plenary.nvim' }, + }, + config = function() + require('cheatsheet').setup() + end, + vim.keymap.set('n', 'sc', ':Cheatsheet', { desc = '[S]earch in [C]eatsheet' }), +} diff --git a/lua/custom/plugins/golang.lua b/lua/custom/plugins/golang.lua new file mode 100644 index 00000000000..2ea6462f79a --- /dev/null +++ b/lua/custom/plugins/golang.lua @@ -0,0 +1,70 @@ +return { + { + 'olexsmir/gopher.nvim', + ft = 'go', + -- branch = "develop" + -- (optional) updates the plugin's dependencies on each update + build = function() + vim.cmd.GoInstallDeps() + end, + ---@module "gopher" + ---@type gopher.Config + opts = {}, + config = function() + require('gopher').setup { + -- log level, you might consider using DEBUG or TRACE for debugging the plugin + log_level = vim.log.levels.INFO, + + -- timeout for running internal commands + timeout = 2000, + + -- timeout for running installer commands(e.g :GoDepsInstall, :GoDepsInstallSync) + installer_timeout = 999999, + + -- user specified paths to binaries + commands = { + go = 'go', + gomodifytags = 'gomodifytags', + gotests = 'gotests', + impl = 'impl', + iferr = 'iferr', + }, + gotests = { + -- a default template that gotess will use. + -- gotets doesn't have template named `default`, we use it to represent absence of the provided template. + template = 'default', + + -- path to a directory containing custom test code templates + template_dir = nil, + + -- use named tests(map with test name as key) in table tests(slice of structs by default) + named = false, + }, + gotag = { + transform = 'snakecase', + + -- default tags to add to struct fields + default_tag = 'json', + + -- default tag option added struct fields, set to nil to disable + -- e.g: `option = "json=omitempty,xml=omitempty` + option = nil, + }, + iferr = { + -- choose a custom error message, nil to use default + -- e.g: `message = 'fmt.Errorf("failed to %w", err)'` + message = nil, + }, + json2go = { + -- command used to open interactive input. + -- e.g: `split`, `botright split`, `tabnew` + interactive_cmd = 'vsplit', + + -- name of autogenerated struct + -- e.g: "MySuperCoolName" + type_name = nil, + }, + } + end, + }, +} diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000000..76b99ac046c --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,64 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + commit = 'e76cb03', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local harpoon = require 'harpoon' + harpoon:setup { + settings = { + save_on_toggle = true, + mark_branch = true, + }, + } + + -- basic telescope configuration + local conf = require('telescope.config').values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require('telescope.pickers') + .new({}, { + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table { + results = file_paths, + }, + previewer = conf.file_previewer {}, + sorter = conf.generic_sorter {}, + }) + :find() + end + + vim.keymap.set('n', '', function() + toggle_telescope(harpoon:list()) + end, { desc = 'Open harpoon window' }) + + vim.keymap.set('n', 'ha', function() + harpoon:list():add() + end, { desc = '[H]arpoon [A]dd mark' }) + + vim.keymap.set('n', '', function() + harpoon:list():select(1) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(2) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(3) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(4) + end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', 'hp', function() + harpoon:list():prev() + end, { desc = '[H]arpoon [P]rev item' }) + vim.keymap.set('n', 'hn', function() + harpoon:list():next() + end, { desc = '[H]arpoon [N]ext item' }) + end, +} diff --git a/lua/custom/plugins/llm.lua b/lua/custom/plugins/llm.lua new file mode 100644 index 00000000000..5d53474d945 --- /dev/null +++ b/lua/custom/plugins/llm.lua @@ -0,0 +1,59 @@ +return { + { + 'milanglacier/minuet-ai.nvim', + + cond = function() + if vim.fn.executable 'ollama' ~= 1 then + vim.schedule(function() + vim.notify('minuet-ai.nvim disabled: ollama not found', vim.log.levels.INFO) + end) + return false + end + return true + end, + + config = function() + require('minuet').setup { + virtualtext = { + auto_trigger_ft = {}, + keymap = { + -- accept whole completion + accept = '', + -- accept one line + accept_line = '', + -- accept n lines (prompts for number) + -- e.g. "A-z 2 CR" will accept 2 lines + accept_n_lines = '', + -- Cycle to prev completion item, or manually invoke completion + prev = '', + -- Cycle to next completion item, or manually invoke completion + next = '', + dismiss = '', + }, + }, + provider = 'openai_fim_compatible', + n_completions = 1, -- recommend for local model for resource saving + -- I recommend beginning with a small context window size and incrementally + -- expanding it, depending on your local computing power. A context window + -- of 512, serves as an good starting point to estimate your computing + -- power. Once you have a reliable estimate of your local computing power, + -- you should adjust the context window to a larger value. + context_window = 512, + provider_options = { + openai_fim_compatible = { + -- For Windows users, TERM may not be present in environment variables. + -- Consider using APPDATA instead. + api_key = 'TERM', + name = 'Ollama', + end_point = 'http://localhost:11434/v1/completions', + model = 'qwen2.5-coder:7b', + optional = { + max_tokens = 56, + top_p = 0.9, + }, + }, + }, + } + end, + }, +} diff --git a/lua/custom/plugins/project.lua b/lua/custom/plugins/project.lua new file mode 100644 index 00000000000..7e7b865db27 --- /dev/null +++ b/lua/custom/plugins/project.lua @@ -0,0 +1,13 @@ +return { + 'DrKJeff16/project.nvim', + dependencies = { -- OPTIONAL + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim', + 'ibhagwan/fzf-lua', + }, + config = function() + require('project').setup() + require('telescope').load_extension 'projects' + end, + vim.keymap.set('n', 'sp', ':Telescope projects', { desc = '[S]earch [P]roject' }), +} diff --git a/lua/custom/plugins/tests.lua b/lua/custom/plugins/tests.lua new file mode 100644 index 00000000000..522f8947cc7 --- /dev/null +++ b/lua/custom/plugins/tests.lua @@ -0,0 +1,31 @@ +return { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-neotest/nvim-nio', + 'nvim-lua/plenary.nvim', + 'antoinemadec/FixCursorHold.nvim', + 'nvim-treesitter/nvim-treesitter', + 'nvim-neotest/neotest-go', + }, + opts = {}, + config = function() + require('neotest').setup { + adapters = { + require 'neotest-go', + }, + output_panel = { + enabled = true, + open = 'botright split | resize 15', + }, + quickfix = { + open = false, + }, + } + vim.keymap.set('n', 't', "lua require('neotest').run.run()", { desc = 'Run Test' }) + vim.keymap.set('n', 'tf', "lua require('neotest').run.run(vim.fn.expand('%'))", { desc = 'Run Test File' }) + vim.keymap.set('n', 'td', "lua require('neotest').run.run(vim.fn.getcwd())", { desc = 'Run Current Test Directory' }) + vim.keymap.set('n', 'tp', "lua require('neotest').output_panel.toggle()", { desc = 'Toggle Test Output Panel' }) + vim.keymap.set('n', 'tl', "lua require('neotest').run.run_last()", { desc = 'Run Last Test' }) + vim.keymap.set('n', 'ts', "lua require('neotest').summary.toggle()", { desc = 'Toggle Test Summary' }) + end, +}