From d38bafbaba99a5dce224afb8fed3b6214ad3accd Mon Sep 17 00:00:00 2001 From: Omixxx Date: Tue, 21 Feb 2023 23:39:26 +0100 Subject: [PATCH] update --- init.lua | 104 ++++++++++++++++++++++------ lua/custom/plugins/auto-session.lua | 4 ++ lua/custom/plugins/autopairs.lua | 8 +++ lua/custom/plugins/barbar.lua | 4 ++ lua/custom/plugins/cmdline.lua | 6 ++ lua/custom/plugins/copilot.lua | 3 + lua/custom/plugins/init.lua | 5 +- lua/custom/plugins/lazygit.lua | 3 + lua/custom/plugins/leap.lua | 6 ++ lua/custom/plugins/neotree.lua | 29 ++++++++ lua/custom/plugins/themes.lua | 18 +++++ 11 files changed, 165 insertions(+), 25 deletions(-) create mode 100644 lua/custom/plugins/auto-session.lua create mode 100644 lua/custom/plugins/autopairs.lua create mode 100644 lua/custom/plugins/barbar.lua create mode 100644 lua/custom/plugins/cmdline.lua create mode 100644 lua/custom/plugins/copilot.lua create mode 100644 lua/custom/plugins/lazygit.lua create mode 100644 lua/custom/plugins/leap.lua create mode 100644 lua/custom/plugins/neotree.lua create mode 100644 lua/custom/plugins/themes.lua diff --git a/init.lua b/init.lua index aeca6d28..4935db43 100644 --- a/init.lua +++ b/init.lua @@ -4,7 +4,7 @@ ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== -Kickstart.nvim is *not* a distribution. +Kickctart.nvim is *not* a distribution. Kickstart.nvim is a template for your own configuration. The goal is that you can read every line of code, top-to-bottom, and understand @@ -35,7 +35,6 @@ I hope you enjoy your Neovim journey, P.S. You can delete this when you're done too. It's your config now :) --]] - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) @@ -87,7 +86,7 @@ require('lazy').setup({ { 'j-hui/fidget.nvim', opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! - 'folke/neodev.nvim', + 'folkenvim_set_keymap/neodev.nvim', }, }, @@ -97,7 +96,7 @@ require('lazy').setup({ }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, + { 'folke/which-key.nvim', opts = {} }, { -- Adds git releated signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { @@ -114,10 +113,6 @@ require('lazy').setup({ { -- Theme inspired by Atom 'navarasu/onedark.nvim', - priority = 1000, - config = function() - vim.cmd.colorscheme 'onedark' - end, }, { -- Set lualine as statusline @@ -144,7 +139,7 @@ require('lazy').setup({ }, -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + { 'numToStr/Comment.nvim', opts = {} }, -- Fuzzy Finder (files, lsp, etc) { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, @@ -172,6 +167,7 @@ require('lazy').setup({ end, }, + -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. @@ -200,6 +196,8 @@ vim.wo.number = true -- Enable mouse mode vim.o.mouse = 'a' +-- enable relativew numbers +vim.o.relativenumber = true -- Sync clipboard between OS and Neovim. -- Remove this option if you want your OS clipboard to remain independent. @@ -240,8 +238,72 @@ vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +-- go from insert to normal with "jj" +vim.api.nvim_set_keymap('i', 'jj', '', { noremap = true }) + +-- save the file with space w +vim.api.nvim_set_keymap('n', 'w', ':Format :w', { noremap = true, silent = true, desc = "save" }) + +-- open file tree view +vim.api.nvim_set_keymap('n', 'ee', ':NeoTreeFocusToggle', + { noremap = true, silent = true, desc = "Open file tree view" }) + +-- open float file tree view +vim.api.nvim_set_keymap('n', 'ef', ':NeoTreeFloatToggle', + { noremap = true, silent = true, desc = "Open float file tree view" }) + +-- Mappa Ctrl+l per spostarsi a destra nel buffer corrente +vim.api.nvim_set_keymap('n', '', 'l', { noremap = true, silent = true }) + +-- Mappa Ctrl+h per spostarsi a sinistra nel buffer corrente +vim.api.nvim_set_keymap('n', '', 'h', { noremap = true, silent = true }) + +-- Mappa Ctrl+j per spostarsi in basso nel buffer corrente +vim.api.nvim_set_keymap('n', '', 'j', { noremap = true, silent = true }) + +-- mappatura per spostarsi a sinistra tra le finestre +vim.api.nvim_set_keymap('n', '', ':BufferPrevious', { noremap = true, silent = true }) + +-- mappatura per spostarsi a destra tra le finestre +vim.api.nvim_set_keymap('n', '', ':BufferNext', { noremap = true, silent = true }) + +-- close the current buffer +vim.api.nvim_set_keymap('n', 'c', ':bd', { noremap = true, silent = true }) + +-- Mapping copilot to +vim.g.copilot_no_tab_map = true +vim.api.nvim_set_keymap("i", "", 'copilot#Accept("")', { silent = true, expr = true }) + +vim.api.nvim_set_keymap('n', ':', 'FineCmdline', { noremap = true }) + +vim.o.swapfile = false + +-- custom requirements +config = function() + require("config.auto-session").setup {} + require("session-lens").setup {} +end + +-- neovide settings +if vim.g.neovide then + -- vim.g.neovide_cursor_animation_length = 0 + vim.g.neovide_cursor_trail_size = 0.8 + vim.g.neovide_cursor_animate_in_insert_mode = true + vim.g.neovide_scale_factor = 1.3 + vim.g.neovide_fullscreen = true + vim.api.nvim_set_keymap("n", "", ":lua vim.g.neovide_scale_factor = vim.g.neovide_scale_factor + 0.1", + { silent = true }) + vim.api.nvim_set_keymap("n", "", ":lua vim.g.neovide_scale_factor = vim.g.neovide_scale_factor - 0.1", + { silent = true }) + vim.api.nvim_set_keymap("n", "", ":lua vim.g.neovide_scale_factor = 1.3", { silent = true }) + vim.g.neovide_floating_blur_amount_x = 2.0 +end + + + -- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` +-- +-- See `:help kim.highlight.on_yank()` local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) vim.api.nvim_create_autocmd('TextYankPost', { callback = function() @@ -250,7 +312,6 @@ vim.api.nvim_create_autocmd('TextYankPost', { group = highlight_group, pattern = '*', }) - -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` require('telescope').setup { @@ -283,6 +344,7 @@ vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set("n", "sk", require('telescope.builtin').keymaps, { desc = "Search Keymaps" }) -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` @@ -353,7 +415,7 @@ require('nvim-treesitter.configs').setup { -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', ']d', vim.diagnostic.goto_next) -vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', 'ld', vim.diagnostic.open_float, { desc = '[LSP] [D]iagnostics' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist) -- LSP settings. @@ -373,15 +435,14 @@ local on_attach = function(_, bufnr) vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + nmap('lr', vim.lsp.buf.rename, '[L]sp [r]ename') + nmap('la', vim.lsp.buf.code_action(), '[L]sp [A]ction') nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- See `:help K` for why this keymap nmap('K', vim.lsp.buf.hover, 'Hover Documentation') @@ -389,11 +450,6 @@ local on_attach = function(_, bufnr) -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) @@ -461,7 +517,7 @@ cmp.setup { end, }, mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs( -4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete {}, [''] = cmp.mapping.confirm { @@ -480,8 +536,8 @@ cmp.setup { [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) + elseif luasnip.jumpable( -1) then + luasnip.jump( -1) else fallback() end @@ -495,3 +551,5 @@ cmp.setup { -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +-- vim: ts=2 sts=2 sw=2 et +-- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/auto-session.lua b/lua/custom/plugins/auto-session.lua new file mode 100644 index 00000000..3c91c78f --- /dev/null +++ b/lua/custom/plugins/auto-session.lua @@ -0,0 +1,4 @@ +return { + "rmagatti/session-lens", + dependencies = { "rmagatti/auto-session", "nvim-telescope/telescope.nvim" }, +} diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..cd5931d4 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,8 @@ +-- File: lua/custom/plugins/autopairs.lua + +return { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup {} + end, +} diff --git a/lua/custom/plugins/barbar.lua b/lua/custom/plugins/barbar.lua new file mode 100644 index 00000000..cbf3e982 --- /dev/null +++ b/lua/custom/plugins/barbar.lua @@ -0,0 +1,4 @@ +return { + 'romgrk/barbar.nvim', + dependencies = 'nvim-tree/nvim-web-devicons', +} diff --git a/lua/custom/plugins/cmdline.lua b/lua/custom/plugins/cmdline.lua new file mode 100644 index 00000000..cc2946ed --- /dev/null +++ b/lua/custom/plugins/cmdline.lua @@ -0,0 +1,6 @@ +return { + 'VonHeikemen/fine-cmdline.nvim', + dependencies = { + { 'MunifTanjim/nui.nvim' } + } +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..0bc50063 --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,3 @@ +return { + "github/copilot.vim" +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..1ad12838 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,5 +1,6 @@ -- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) +--- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { +} diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000..6b787358 --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,3 @@ +return { + 'kdheepak/lazygit.nvim' +} diff --git a/lua/custom/plugins/leap.lua b/lua/custom/plugins/leap.lua new file mode 100644 index 00000000..f7153d54 --- /dev/null +++ b/lua/custom/plugins/leap.lua @@ -0,0 +1,6 @@ +return { + "ggandor/leap.nvim", + config = function() + require('leap').add_default_mappings() + end +} diff --git a/lua/custom/plugins/neotree.lua b/lua/custom/plugins/neotree.lua new file mode 100644 index 00000000..f2693ab9 --- /dev/null +++ b/lua/custom/plugins/neotree.lua @@ -0,0 +1,29 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function() + -- Unless you are still migrating, remove the deprecated commands from v1.x + vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + + require('neo-tree').setup { + close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab + popup_border_style = "rounded", + enable_git_status = true, + enable_diagnostics = true, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + } + end, +} diff --git a/lua/custom/plugins/themes.lua b/lua/custom/plugins/themes.lua new file mode 100644 index 00000000..875b9d09 --- /dev/null +++ b/lua/custom/plugins/themes.lua @@ -0,0 +1,18 @@ +return { + + { + + 'folke/tokyonight.nvim', + priority = 1000, + config = function() + vim.cmd.colorscheme 'tokyonight-night' + end, + + }, + + { -- Theme inspired by Atom + 'navarasu/onedark.nvim', + }, + + +}