From 030c0482c8e2d06061b6bf2c7cba8dca637198c9 Mon Sep 17 00:00:00 2001 From: hollorol Date: Mon, 29 Jul 2024 11:26:35 +0200 Subject: [PATCH] Initial neovim config -- the end of vimscript for me :) --- .gitignore | 1 + init.lua | 4 ++++ lua/config/keymaps.lua | 20 ++++++++++++++++++++ lua/config/lazy.lua | 24 ++++++++++++++++++++++++ lua/config/options.lua | 11 +++++++++++ lua/config/plugins/angr.lua | 9 +++++++++ lua/config/plugins/easymotion.lua | 10 ++++++++++ lua/config/plugins/fzf.lua | 10 ++++++++++ lua/config/plugins/init.lua | 9 +++++++++ lua/config/plugins/nvimr.lua | 23 +++++++++++++++++++++++ lua/config/plugins/tcomment_vim.lua | 3 +++ lua/config/plugins/whichkey.lua | 18 ++++++++++++++++++ lua/custom/functions.lua | 9 +++++++++ 13 files changed, 151 insertions(+) create mode 100644 .gitignore create mode 100644 init.lua create mode 100644 lua/config/keymaps.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/options.lua create mode 100644 lua/config/plugins/angr.lua create mode 100644 lua/config/plugins/easymotion.lua create mode 100644 lua/config/plugins/fzf.lua create mode 100644 lua/config/plugins/init.lua create mode 100644 lua/config/plugins/nvimr.lua create mode 100644 lua/config/plugins/tcomment_vim.lua create mode 100644 lua/config/plugins/whichkey.lua create mode 100644 lua/custom/functions.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..51b75a7 --- /dev/null +++ b/init.lua @@ -0,0 +1,4 @@ +require("config.options") +require("config.keymaps") +require("config.lazy") +require("custom.functions") diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..23f2022 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,20 @@ +-- Insert mode bindings +vim.keymap.set('i','jk','', {noremap=true, silent=true}) +vim.keymap.set('i','÷','()i', {noremap=true, silent=true}) + +vim.keymap.set('n','',':b#', {noremap=true, silent=true}) +vim.keymap.set('n', 'cd', ':cd %:p:h', {noremap=true, silent=true}) +vim.keymap.set('n', 'ff', ':Files', { noremap = true, silent = true }) +vim.keymap.set('n', 'fg', ':GFiles', { noremap = true, silent = true }) +vim.keymap.set('n', 'bb', ':Buffers', { noremap = true, silent = true }) +vim.keymap.set('n', 'fh', ':Helptags', { noremap = true, silent = true }) +vim.keymap.set('n', '-', '/', { noremap = true, silent = true }) +vim.keymap.set('n', '', function() vim.cmd('e ~/.config/nvim/init.vim') end, { noremap = true, silent = true }) +vim.keymap.set('n','',':set hlsearch!',{ noremap = true, silent = true }) +vim.keymap.set('n','',':set number!',{ noremap = true, silent = true }) +vim.keymap.set('n','ss', function() vim.cmd('LinesWithPreview') end,{ noremap = true, silent = true }) +vim.keymap.set('n', 'á', '`', { noremap = true, silent = true }) +vim.keymap.set('n', 'z7', 'z=', { noremap = true, silent = true }) +vim.keymap.set('n', '', ':set ignorecase!', { noremap = true, silent = true }) +vim.keymap.set('n', '',':set spell! spelllang=hu', { noremap = true, silent = true }) +vim.keymap.set('n', '',':set spell! spelllang=en', { noremap = true, silent = true }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..549469d --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,24 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) + +-- Setup lazy.nvim +require("lazy").setup("config.plugins") + diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..001c8a5 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,11 @@ +vim.opt.hlsearch = false -- Disable highlighting search matches +vim.opt.hidden = true -- Allow background buffers +vim.opt.cindent = true +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.hidden = true +vim.opt.mouse="a" +vim.opt.clipboard="unnamedplus" +vim.g.mapleader = " " +vim.g.maplocalleader = "," diff --git a/lua/config/plugins/angr.lua b/lua/config/plugins/angr.lua new file mode 100644 index 0000000..82d1f65 --- /dev/null +++ b/lua/config/plugins/angr.lua @@ -0,0 +1,9 @@ +return { + "hollorol/angr.vim", + lazy = false, + priority = 1000, + config = function() + -- load the colorscheme here + vim.cmd([[colorscheme angr]]) + end, +} diff --git a/lua/config/plugins/easymotion.lua b/lua/config/plugins/easymotion.lua new file mode 100644 index 0000000..5138656 --- /dev/null +++ b/lua/config/plugins/easymotion.lua @@ -0,0 +1,10 @@ +return { + { + 'easymotion/vim-easymotion', + config = function() + -- EasyMotion configuration + vim.api.nvim_set_keymap('n', '', '(easymotion-s2)', {}) + vim.api.nvim_set_keymap('n', '', '(easymotion-lineforward)', {}) + end + }, +} diff --git a/lua/config/plugins/fzf.lua b/lua/config/plugins/fzf.lua new file mode 100644 index 0000000..146506d --- /dev/null +++ b/lua/config/plugins/fzf.lua @@ -0,0 +1,10 @@ +return { + { + 'junegunn/fzf', + run = function() vim.fn['fzf#install']() end + }, + { + 'junegunn/fzf.vim', + cmd = { 'Files','GFiles','Buffers','Helptags', 'Ag', 'Rg' }, -- Load when invoking FZF commands + } +} diff --git a/lua/config/plugins/init.lua b/lua/config/plugins/init.lua new file mode 100644 index 0000000..0f5e83b --- /dev/null +++ b/lua/config/plugins/init.lua @@ -0,0 +1,9 @@ +return { + {'tpope/vim-fugitive'}, + {'gorkunov/smartpairs.vim'}, + {'SirVer/ultisnips'}, + {'tpope/vim-surround'}, + {'mattn/emmet-vim', + ft = { 'html', 'css', 'javascript', 'typescript', 'vue' }, + } +} diff --git a/lua/config/plugins/nvimr.lua b/lua/config/plugins/nvimr.lua new file mode 100644 index 0000000..eef99ff --- /dev/null +++ b/lua/config/plugins/nvimr.lua @@ -0,0 +1,23 @@ +return { + { + "R-nvim/R.nvim", + lazy = false + }, + { + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + config = function () + require("nvim-treesitter.configs").setup({ + ensure_installed = { "markdown", "markdown_inline", "r", "rnoweb", "yaml" }, + }) + end + }, + "R-nvim/cmp-r", + { + "hrsh7th/nvim-cmp", + config = function() + require("cmp").setup({ sources = {{ name = "cmp_r" }}}) + require("cmp_r").setup({ }) + end, + } +} diff --git a/lua/config/plugins/tcomment_vim.lua b/lua/config/plugins/tcomment_vim.lua new file mode 100644 index 0000000..4dbdcc4 --- /dev/null +++ b/lua/config/plugins/tcomment_vim.lua @@ -0,0 +1,3 @@ +return{ + 'tomtom/tcomment_vim', +} diff --git a/lua/config/plugins/whichkey.lua b/lua/config/plugins/whichkey.lua new file mode 100644 index 0000000..3e56572 --- /dev/null +++ b/lua/config/plugins/whichkey.lua @@ -0,0 +1,18 @@ +return { +"folke/which-key.nvim", + event = "VeryLazy", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, +} diff --git a/lua/custom/functions.lua b/lua/custom/functions.lua new file mode 100644 index 0000000..3e5df69 --- /dev/null +++ b/lua/custom/functions.lua @@ -0,0 +1,9 @@ +-- Alternatively, using a Lua function +local function lines_with_preview() + local current_file = vim.fn.fnameescape(vim.fn.expand('%')) + local rg_command = string.format("rg --with-filename --column --line-number --no-heading --color=always --smart-case . %s", current_file) + local fzf_command = string.format("call fzf#vim#grep('%s', 1, fzf#vim#with_preview({'options': '--delimiter : --nth 4.. --no-sort'}, 'up:50%%', '?'), 1)", rg_command) + vim.cmd(fzf_command) +end + +vim.api.nvim_create_user_command('LinesWithPreview', lines_with_preview, {})