From 55541787e3dc86eab9bf3544e77e2a0b333fe188 Mon Sep 17 00:00:00 2001 From: Dino Danic Date: Tue, 25 Mar 2025 09:13:18 +0100 Subject: [PATCH] update config --- init.lua | 124 ++++++++++++++--------------- lua/custom/colors.lua | 2 + lua/custom/keymaps.lua | 2 +- lua/custom/plugins/init.lua | 37 ++++++++- lua/kickstart/plugins/neo-tree.lua | 21 ++++- 5 files changed, 118 insertions(+), 68 deletions(-) create mode 100644 lua/custom/colors.lua diff --git a/init.lua b/init.lua index 9ec6f038..a1ea8ed6 100644 --- a/init.lua +++ b/init.lua @@ -143,15 +143,20 @@ require('lazy').setup({ }, config = function() -- [[ Configure Telescope ]] + local actions = {} require('telescope').setup { -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, + defaults = { + mappings = { + i = { + [''] = 'to_fuzzy_refine', + [''] = 'move_selection_next', + [''] = 'move_selection_previous', + }, + }, + }, -- pickers = {} extensions = { ['ui-select'] = { @@ -164,14 +169,36 @@ require('lazy').setup({ pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') + -- Available Telescope themes: + -- get_dropdown() - A dropdown menu style with a floating window + -- get_cursor() - A cursor-based selection style with a floating window + -- get_ivy() - The Ivy style with a vertical list layout + -- get_center() - A centered layout with a floating window + -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + + vim.keymap.set('n', 'sf', function() + builtin.find_files(require('telescope.themes').get_dropdown()) + end, { desc = '[S]earch [F]iles' }) + + vim.keymap.set('n', 'f', function() + builtin.find_files(require('telescope.themes').get_dropdown()) + end, { desc = '[S]earch [F]iles' }) + + vim.keymap.set('n', 'sg', function() + builtin.live_grep(require('telescope.themes').get_ivy()) + end, { desc = '[S]earch by [G]rep' }) + + vim.keymap.set('n', 'F', function() + builtin.live_grep(require('telescope.themes').get_ivy()) + end, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + -- vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) 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)' }) @@ -224,31 +251,6 @@ require('lazy').setup({ 'hrsh7th/cmp-nvim-lsp', }, config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - -- This function gets run when an LSP attaches to a particular buffer. -- That is to say, every time a new file is opened that is associated with -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this @@ -289,7 +291,7 @@ require('lazy').setup({ -- Fuzzy find all the symbols in your current workspace. -- Similar to document symbols, except searches over your entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + -- map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. @@ -297,12 +299,15 @@ require('lazy').setup({ -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) + -- i will comment this out becouse of close c + -- map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + vim.diagnostic.config { virtual_text = false } + -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) ---@param client vim.lsp.Client ---@param method vim.lsp.protocol.Method @@ -531,12 +536,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, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -585,7 +590,7 @@ require('lazy').setup({ -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.confirm { select = true }, --[''] = cmp.mapping.select_next_item(), --[''] = cmp.mapping.select_prev_item(), @@ -631,34 +636,22 @@ require('lazy').setup({ end, }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. - config = function() - ---@diagnostic disable-next-line: missing-fields - require('tokyonight').setup { - styles = { - comments = { italic = false }, -- Disable italics in comments - }, - } - - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' - end, - }, - -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - { -- Collection of various small independent plugins/modules 'echasnovski/mini.nvim', config = function() + local gen_loader = require('mini.snippets').gen_loader + require('mini.snippets').setup { + snippets = { + -- Load custom file with global snippets first (adjust for Windows) + gen_loader.from_file '~/.config/nvim/snippets/global.json', + + -- Load snippets based on current language by reading files from + -- "snippets/" subdirectories from 'runtimepath' directories. + gen_loader.from_lang(), + }, + } -- Better Around/Inside textobjects -- -- Examples: @@ -769,3 +762,6 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et + +-- load after plugins +require 'custom.colors' diff --git a/lua/custom/colors.lua b/lua/custom/colors.lua new file mode 100644 index 00000000..ca86936d --- /dev/null +++ b/lua/custom/colors.lua @@ -0,0 +1,2 @@ +vim.cmd [[ colorscheme rose-pine-main ]] +-- vim.cmd [[ colorscheme tokyonight ]] diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua index 5b6009f5..7f0f6e8c 100644 --- a/lua/custom/keymaps.lua +++ b/lua/custom/keymaps.lua @@ -20,8 +20,8 @@ vim.keymap.set('n', 'd', 'lua vim.diagnostic.open_float()', { d -- Files vim.keymap.set('n', 'q', 'q!', { desc = '[Q]uit' }) vim.keymap.set('n', 'w', 'w!', { desc = '[W]rite file' }) -vim.keymap.set('n', '/', '(comment_toggle_linewise_current)', { desc = 'Toggle comment line' }) vim.keymap.set('n', '.', 'luafile %', { desc = 'Source Lua file' }) +vim.keymap.set('n', '/', '(comment_toggle_linewise_current)', { desc = 'Toggle comment line' }) vim.keymap.set('v', '/', '(comment_toggle_linewise_visual)', { desc = 'Toggle comment for selection' }) -- delete single character without copying into register diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 7c7f007a..341da414 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -3,6 +3,7 @@ -- -- See the kickstart.nvim README for more information return { + -------------------------------------UI------------------------------------- { 'akinsho/bufferline.nvim', version = '*', @@ -11,6 +12,34 @@ return { require('bufferline').setup {} end, }, + -------------------------------------UTILS------------------------------------- + { + 'kdheepak/lazygit.nvim', + lazy = true, + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { 'lg', 'LazyGit', desc = 'LazyGit' }, + }, + }, + + { + 'windwp/nvim-ts-autotag', + config = function() + require('nvim-ts-autotag').setup() + end, + }, { 'mikavilpas/yazi.nvim', event = 'VeryLazy', @@ -46,9 +75,13 @@ return { { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, }, }, - -------------------------------------COLORS------------------------------------- - --- { 'catppuccin/nvim', as = 'catppuccin' }, { 'rose-pine/neovim', name = 'rose-pine' }, + { + 'folke/tokyonight.nvim', + lazy = false, + priority = 1000, + opts = {}, + }, } diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index 3b266fe6..bd2057ca 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -11,7 +11,7 @@ return { }, cmd = 'Neotree', keys = { - { 'e', ':Neotree toggle', desc = 'NeoTree reveal', silent = true }, + { 'e', ':Neotree toggle reveal', desc = 'NeoTree reveal', silent = true }, }, opts = { filesystem = { @@ -22,4 +22,23 @@ return { }, }, }, + config = function() + require('neo-tree').setup { + popup_border_style = 'rounded', + close_if_last_window = true, + enable_git_status = true, + enable_diagnostics = true, + event_handlers = { + { + event = 'file_opened', + handler = function(file_path) + -- auto close + -- vimc.cmd("Neotree close") + -- OR + require('neo-tree.command').execute { action = 'close' } + end, + }, + }, + } + end, }