From 0f179a9bd996db10796c726381bcfb5b491b2317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sun, 10 Nov 2024 12:23:44 +0100 Subject: [PATCH] first commit --- .gitignore | 3 ++ after/plugin/colors.lua | 9 ++++ after/plugin/comment.lua | 2 + after/plugin/fugitive.lua | 1 + after/plugin/go.lua | 11 +++++ after/plugin/harpoon.lua | 9 ++++ after/plugin/lsp.lua | 62 ++++++++++++++++++++++++ after/plugin/telescope.lua | 7 +++ after/plugin/treesitter.lua | 16 +++++++ after/plugin/undotree.lua | 1 + init.lua | 1 + lazy-lock.json | 27 +++++++++++ lua/zak/init.lua | 3 ++ lua/zak/plugins.lua | 94 +++++++++++++++++++++++++++++++++++++ lua/zak/remap.lua | 80 +++++++++++++++++++++++++++++++ lua/zak/set.lua | 33 +++++++++++++ 16 files changed, 359 insertions(+) create mode 100644 .gitignore create mode 100644 after/plugin/colors.lua create mode 100644 after/plugin/comment.lua create mode 100644 after/plugin/fugitive.lua create mode 100644 after/plugin/go.lua create mode 100644 after/plugin/harpoon.lua create mode 100644 after/plugin/lsp.lua create mode 100644 after/plugin/telescope.lua create mode 100644 after/plugin/treesitter.lua create mode 100644 after/plugin/undotree.lua create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/zak/init.lua create mode 100644 lua/zak/plugins.lua create mode 100644 lua/zak/remap.lua create mode 100644 lua/zak/set.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..40b65e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +packer_compiled.lua +undodir/ + diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua new file mode 100644 index 0000000..4352176 --- /dev/null +++ b/after/plugin/colors.lua @@ -0,0 +1,9 @@ +function Colors(color) + color = color or "catppuccin" + vim.cmd.colorscheme(color) + + -- vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + -- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +end + +Colors() diff --git a/after/plugin/comment.lua b/after/plugin/comment.lua new file mode 100644 index 0000000..32df108 --- /dev/null +++ b/after/plugin/comment.lua @@ -0,0 +1,2 @@ +require("Comment").setup() + diff --git a/after/plugin/fugitive.lua b/after/plugin/fugitive.lua new file mode 100644 index 0000000..80c9070 --- /dev/null +++ b/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gs", vim.cmd.Git) diff --git a/after/plugin/go.lua b/after/plugin/go.lua new file mode 100644 index 0000000..6642e56 --- /dev/null +++ b/after/plugin/go.lua @@ -0,0 +1,11 @@ +local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require('go.format').goimports() + end, + group = format_sync_grp, +}) + +require('go').setup() + diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua new file mode 100644 index 0000000..09aded2 --- /dev/null +++ b/after/plugin/harpoon.lua @@ -0,0 +1,9 @@ +local mark = require("harpoon.mark") +local ui = require("harpoon.ui") + +vim.keymap.set("n", "a", mark.add_file) +vim.keymap.set("n", "", ui.toggle_quick_menu) + +vim.keymap.set("n", "", function() ui.nav_file(1) end) +vim.keymap.set("n", "", function() ui.nav_file(2) end) +vim.keymap.set("n", "", function() ui.nav_file(3) end) diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..a284a20 --- /dev/null +++ b/after/plugin/lsp.lua @@ -0,0 +1,62 @@ +local lsp = require("lsp-zero") + +lsp.preset("recommended") + +require('mason').setup({}) +require('mason-lspconfig').setup({ + ensure_installed = { + 'eslint', + 'rust_analyzer', + }, + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + }, +}) + +local cmp = require('cmp') +local cmp_select = { behavior = cmp.SelectBehavior.Select } +cmp.setup({ + sources = { + {name = 'nvim_lsp'}, + {name = 'cmp-buffer'}, + {name = 'cmp-path'}, + {name = 'copilot'}, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({select = true}), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }) + }) +}) + +lsp.set_preferences({ + sign_icons = {} +}) + +lsp.on_attach(function(client, bufnr) + local opts = { buffer=bufnr, remap=false } + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) +end) + +lsp.setup() + +-- require("lspconfig").gopls.setup({ +-- -- your gopls setup +-- }) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua new file mode 100644 index 0000000..b5b1af4 --- /dev/null +++ b/after/plugin/telescope.lua @@ -0,0 +1,7 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'pf', builtin.find_files, {}) +vim.keymap.set('n', 'pg', builtin.git_files, {}) +vim.keymap.set('n', 'pb', builtin.buffers, {}) +vim.keymap.set('n', 'ps', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..63391b9 --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,16 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "javascript", "c", "cpp", "lua", "vim", "vimdoc", "query" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, +} diff --git a/after/plugin/undotree.lua b/after/plugin/undotree.lua new file mode 100644 index 0000000..b6b9276 --- /dev/null +++ b/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..51b2513 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("zak") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..19853d4 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,27 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" }, + "catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "copilot.vim": { "branch": "release", "commit": "87038123804796ca7af20d1b71c3428d858a9124" }, + "go.nvim": { "branch": "master", "commit": "2153f9ee6178dfd625b1a874eab6399fd0a2d984" }, + "guihua.lua": { "branch": "master", "commit": "d783191eaa75215beae0c80319fcce5e6b3beeda" }, + "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, + "lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "ab2a3413646fedd77aa0eab4214a6473e62f6a64" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, + "nvim-lspconfig": { "branch": "master", "commit": "d01864641c6e43c681c3e9f6cf4745c75fdd9dcc" }, + "nvim-treesitter": { "branch": "master", "commit": "0603b3e3d21ebe2fa82dc5361a3d500e0d3ad3a8" }, + "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope.nvim": { "branch": "master", "commit": "d829aa64059001ee7b2c8c8aa9c4e6df0b17d893" }, + "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, + "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, + "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } +} diff --git a/lua/zak/init.lua b/lua/zak/init.lua new file mode 100644 index 0000000..18e19fa --- /dev/null +++ b/lua/zak/init.lua @@ -0,0 +1,3 @@ +require("zak.remap") +require("zak.plugins") +require("zak.set") diff --git a/lua/zak/plugins.lua b/lua/zak/plugins.lua new file mode 100644 index 0000000..41085fd --- /dev/null +++ b/lua/zak/plugins.lua @@ -0,0 +1,94 @@ +-- This file can be loaded by calling `lua require('plugins')` from your init.vim + +-- Bootstrap lazy.nvim if not already installed +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +return require('lazy').setup({ + 'github/copilot.vim', + { + 'numToStr/Comment.nvim', + opts = { + -- add any options here + }, + lazy = false, + }, + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.7', + dependencies = { 'nvim-lua/plenary.nvim' } + }, + { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, + -- { + -- 'rose-pine/neovim', + -- name = 'rose-pine', + -- config = function() + -- vim.cmd('colorscheme rose-pine') + -- end + -- }, + + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate' + }, + 'nvim-treesitter/playground', + + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' + }, + 'theprimeagen/harpoon', + 'mbbill/undotree', + 'tpope/vim-fugitive', + + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + dependencies = { + -- Uncomment the two plugins below if you want to manage the language servers from neovim + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + + 'neovim/nvim-lspconfig', + 'hrsh7th/nvim-cmp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-nvim-lua', + 'L3MON4D3/LuaSnip', + } + }, + -- Lua + { + "folke/zen-mode.nvim", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + }, + { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = {"CmdlineEnter"}, + ft = {"go", 'gomod'}, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries +} +}) diff --git a/lua/zak/remap.lua b/lua/zak/remap.lua new file mode 100644 index 0000000..f92b518 --- /dev/null +++ b/lua/zak/remap.lua @@ -0,0 +1,80 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) + +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") +vim.keymap.set("n", "", "") + +-- greatest remap ever +vim.keymap.set("x", "p", [["_dP]]) + +-- next greatest remap ever : asbjornHaland +vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set({"n", "v"}, "d", [["_d]]) + +-- This is going to get me cancelled +vim.keymap.set("i", "", "") + +vim.keymap.set("n", "Q", "") +vim.keymap.set("n", "f", vim.lsp.buf.format) + +vim.keymap.set("n", "", "cnextzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") +vim.keymap.set("n", "j", "lprevzz") + +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) + +vim.keymap.set("n", "so", function() + vim.cmd("so") +end) + +-- Function to get config directory based on OS +local function get_config_dir() + if vim.fn.has('win32') == 1 then + return vim.fn.stdpath('config') + else + return '~/.config/nvim' + end +end + +-- Create the mapping +vim.keymap.set('n', 'cd', function() + -- Get the config directory + local config_dir = get_config_dir() + + -- Change to the config directory + vim.cmd('cd ' .. config_dir) + + -- Open file explorer in the config directory + vim.cmd('Ex ' .. config_dir) +end, { desc = 'Jump to Neovim config directory' }) + +vim.keymap.set('n', 'z', function() + require("zen-mode").toggle({ + window = { + width = .65, -- width will be 85% of the editor width + options = {} + }, + plugins = { + options = { + enabled = true, + ruler = true, -- disables the ruler text in the cmd line area + showcmd = true, -- disables the command in the last line of the screen + -- you may turn on/off statusline in zen mode by setting 'laststatus' + -- statusline will be shown only if 'laststatus' == 3 + laststatus = 3, + } + } + }) +end, { desc = 'Zen Mode' }) diff --git a/lua/zak/set.lua b/lua/zak/set.lua new file mode 100644 index 0000000..0b6539d --- /dev/null +++ b/lua/zak/set.lua @@ -0,0 +1,33 @@ +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = "C:/Users/zakla/.undodir" +vim.opt.undofile = true +vim.opt.shellcmdflag = "-ic" +vim.opt.clipboard = 'unnamedplus' + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.opt.colorcolumn = "80"