diff --git a/init.lua b/init.lua index a34fdd3..9579ead 100644 --- a/init.lua +++ b/init.lua @@ -25,6 +25,8 @@ vim.cmd("autocmd FileType yaml,yaml.ansible setlocal indentkeys-=0#") -- don't use NeoVim's thin cursor vim.opt.guicursor = "" +vim.o.mouse = "" + require('plugins') require("colorschemes") @@ -33,17 +35,17 @@ vim.cmd("hi MatchParen cterm=bold,underline gui=bold,underline") vim.api.nvim_set_keymap("n", "", "", { noremap = true }) vim.g.mapleader = " " -local harpoon_ui = require("harpoon.ui") -local harpoon_mark = require("harpoon.mark") -for _, mode in ipairs({"n", "i", "v"}) do - vim.keymap.set(mode, '', harpoon_ui.toggle_quick_menu) - vim.keymap.set(mode, '', harpoon_mark.add_file) - vim.keymap.set(mode, '', function() harpoon_ui.nav_file(1) end, { noremap = true }) - vim.keymap.set(mode, '', function() harpoon_ui.nav_file(2) end, { noremap = true }) - vim.keymap.set(mode, '', function() harpoon_ui.nav_file(3) end, { noremap = true }) - vim.keymap.set(mode, '', function() harpoon_ui.nav_file(4) end, { noremap = true }) - vim.keymap.set(mode, '', function() harpoon_ui.nav_file(5) end, { noremap = true }) -end +--local harpoon_ui = require("harpoon.ui") +--local harpoon_mark = require("harpoon.mark") +--vim.keymap.set("n", '', harpoon_ui.toggle_quick_menu) +--for _, mode in ipairs({"n", "i", "v"}) do +-- vim.keymap.set(mode, '', harpoon_mark.add_file) +-- vim.keymap.set(mode, '', function() harpoon_ui.nav_file(1) end, { noremap = true }) +-- vim.keymap.set(mode, '', function() harpoon_ui.nav_file(2) end, { noremap = true }) +-- vim.keymap.set(mode, '', function() harpoon_ui.nav_file(3) end, { noremap = true }) +-- vim.keymap.set(mode, '', function() harpoon_ui.nav_file(4) end, { noremap = true }) +-- vim.keymap.set(mode, '', function() harpoon_ui.nav_file(5) end, { noremap = true }) +--end for _, mode in ipairs({"n", "v"}) do vim.api.nvim_set_keymap(mode, "", "g", { noremap = true }) @@ -58,9 +60,9 @@ vim.api.nvim_set_keymap('v', "", ":MoveBlock(1)", { noremap = true }) vim.api.nvim_set_keymap('v', "", ":MoveBlock(-1)", { noremap = true }) vim.api.nvim_set_keymap("n", "o", "lua vim.diagnostic.open_float()", { noremap = true }) -vim.api.nvim_set_keymap("n", "", "lua vim.diagnostic.open_float()", { noremap = true }) +--vim.api.nvim_set_keymap("n", "", "lua vim.diagnostic.open_float()", { noremap = true }) vim.api.nvim_set_keymap("n", "i", "lua vim.lsp.buf.code_action()", { noremap = true }) -vim.api.nvim_set_keymap("n", "", "lua vim.lsp.buf.code_action()", { noremap = true }) +--vim.api.nvim_set_keymap("n", "", "lua vim.lsp.buf.code_action()", { noremap = true }) require('telescope').setup({ initial_mode = "normal" @@ -68,12 +70,18 @@ require('telescope').setup({ local builtin = require('telescope.builtin') vim.keymap.set('n', 'p', builtin.find_files, {}) --- toggle numbers with Alt+N +-- toggle numbers and diagnostics with Alt+N vim.keymap.set( "n", "", function() vim.o.number = not vim.o.number; + if not vim.diagnostic.get_next() then return end + if vim.o.number then + vim.diagnostic.show() + else + vim.diagnostic.hide() + end end ) @@ -126,53 +134,32 @@ require('treesitter') require('nvim_comment').setup() --vim.keymap.set('v', '', "'<,'>CommentToggle") +vim.keymap.set('v', 'C-/', "'<,'>CommentToggle") +vim.keymap.set('n', 'C-/', "CommentToggle") --vim.keymap.set('n', '', "CommentToggle") +-- format on save +--vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] + -- require('nvim-tree').setup() --- -- trouble.nvim mappings --- vim.api.nvim_set_keymap("n", "xx", "Trouble", --- {silent = true, noremap = true} --- ) --- vim.api.nvim_set_keymap("n", "xw", "Trouble workspace_diagnostics", --- {silent = true, noremap = true} --- ) --- vim.api.nvim_set_keymap("n", "xd", "Trouble document_diagnostics", --- {silent = true, noremap = true} --- ) --- vim.api.nvim_set_keymap("n", "xl", "Trouble loclist", --- {silent = true, noremap = true} --- ) --- vim.api.nvim_set_keymap("n", "xq", "Trouble quickfix", --- {silent = true, noremap = true} --- ) --- vim.api.nvim_set_keymap("n", "gR", "Trouble lsp_references", --- {silent = true, noremap = true} --- ) --- +require('exrc').setup() +require('bufferline').setup() + +vim.cmd [[ +fu! SaveSession() + if filereadable(getcwd() . '/Cargo.toml') + execute 'mksession! ' . getcwd() . '/.session.vim' + endif +endfunction + +fu! RestoreSession() + if filereadable(getcwd() . '/.session.vim') + execute 'so ' . getcwd() . '/.session.vim' + endif +endfunction + +autocmd VimLeavePre * call SaveSession() +autocmd VimEnter * nested call RestoreSession() +]] --- original init.vim --- syntax on --- hi MatchParen ctermfg=none ctermbg=none cterm=bold,underline gui=bold,underline guifg=fg guibg=bg --- --- filetype plugin indent on --- set number --- "set relativenumber --- set path+=** --- set noswapfile --- set wildmenu --- set backspace=indent,eol,start --- set undodir=~/.cache/nvim/undo --- set undofile --- set incsearch --- set smartindent --- set ic --- "set colorcolumn=88 --- set et --- set ts=4 --- set sw=4 --- "set showmatch --- set hlsearch incsearch --- "highlight ColorColumn ctermbg=9 --- --- lua require('plugins') diff --git a/lua/plugins.lua b/lua/plugins.lua index aa0d65d..653c126 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -31,6 +31,8 @@ packer.startup( } use 'ThePrimeagen/harpoon' use 'terrortylor/nvim-comment' + use 'MunifTanjim/exrc.nvim' + use { 'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons' } --use { -- 'kyazdani42/nvim-tree.lua', -- --requires = { diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua index d4244f3..88e6aad 100644 --- a/plugin/packer_compiled.lua +++ b/plugin/packer_compiled.lua @@ -9,23 +9,26 @@ vim.api.nvim_command('packadd packer.nvim') local no_errors, error_msg = pcall(function() - local time - local profile_info - local should_profile = false - if should_profile then - local hrtime = vim.loop.hrtime - profile_info = {} - time = function(chunk, start) - if start then - profile_info[chunk] = hrtime() - else - profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 - end +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +local time +local profile_info +local should_profile = false +if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 end - else - time = function(chunk, start) end end - +else + time = function(chunk, start) end +end + local function save_profiles(threshold) local sorted_times = {} for chunk_name, time_taken in pairs(profile_info) do @@ -38,8 +41,10 @@ local function save_profiles(threshold) results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' end end + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end - _G._packer = _G._packer or {} _G._packer.profile_output = results end @@ -69,19 +74,101 @@ end time([[try_loadstring definition]], false) time([[Defining packer_plugins]], true) _G.packer_plugins = { + catppuccin = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/catppuccin", + url = "https://github.com/catppuccin/nvim" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["cmp-snippy"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/cmp-snippy", + url = "https://github.com/dcampos/cmp-snippy" + }, + ["exrc.nvim"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/exrc.nvim", + url = "https://github.com/MunifTanjim/exrc.nvim" + }, + harpoon = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/harpoon", + url = "https://github.com/ThePrimeagen/harpoon" + }, + ["move.nvim"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/move.nvim", + url = "https://github.com/fedepujol/move.nvim" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-comment"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-comment", + url = "https://github.com/terrortylor/nvim-comment" + }, ["nvim-lspconfig"] = { loaded = true, path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", url = "https://github.com/neovim/nvim-lspconfig" }, + ["nvim-snippy"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-snippy", + url = "https://github.com/dcampos/nvim-snippy" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, ["packer.nvim"] = { loaded = true, path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/packer.nvim", url = "https://github.com/wbthomason/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + ["tokyonight.nvim"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/tokyonight.nvim", + url = "https://github.com/folke/tokyonight.nvim" + }, + ["vim-lastplace"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/vim-lastplace", + url = "https://github.com/farmergreg/vim-lastplace" + }, + ["vim-visual-multi"] = { + loaded = true, + path = "/home/ateijelo/.local/share/nvim/site/pack/packer/start/vim-visual-multi", + url = "https://github.com/mg979/vim-visual-multi" } } time([[Defining packer_plugins]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = false + if should_profile then save_profiles() end end)