diff --git a/private_dot_config/nvim/init.lua b/private_dot_config/nvim/init.lua new file mode 100644 index 0000000..19aae43 --- /dev/null +++ b/private_dot_config/nvim/init.lua @@ -0,0 +1,3 @@ +require("config.lazy") +require("config.set") +require("config.remaps") diff --git a/private_dot_config/nvim/lazy-lock.json b/private_dot_config/nvim/lazy-lock.json new file mode 100644 index 0000000..0f5c256 --- /dev/null +++ b/private_dot_config/nvim/lazy-lock.json @@ -0,0 +1,18 @@ +{ + "LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" }, + "catppuccin": { "branch": "main", "commit": "c89184526212e04feffbddda9d06b041a8fca416" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, + "lazy.nvim": { "branch": "main", "commit": "59334064f8604ca073791c25dcc5c9698865406e" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "155eac5d8609a2f110041f8ac3491664cc126354" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-lspconfig": { "branch": "master", "commit": "e688b486fe9291f151eae7e5c0b5a5c4ef980847" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" } +} diff --git a/private_dot_config/nvim/lua/config/lazy.lua b/private_dot_config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..7bc4bf8 --- /dev/null +++ b/private_dot_config/nvim/lua/config/lazy.lua @@ -0,0 +1,36 @@ +-- 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) +vim.api.nvim_set_keymap('', "", "", { noremap = true, silent = true }) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/private_dot_config/nvim/lua/config/remaps.lua b/private_dot_config/nvim/lua/config/remaps.lua new file mode 100644 index 0000000..8026292 --- /dev/null +++ b/private_dot_config/nvim/lua/config/remaps.lua @@ -0,0 +1,13 @@ +-- shift code -- +vim.keymap.set('x', '>', ">gv", { desc = "Shift code right" }) +vim.keymap.set('x', '<', "ca', vim.lsp.buf.code_action, { noremap = true, silent = true, desc = "Code action" }) + +vim.keymap.set('n', 'cf', vim.lsp.buf.format, { desc = "Code format" }) + +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = "Go to definition" }) +vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = "Go to implementation" }) + +vim.keymap.set('n', 'r', vim.lsp.buf.rename, { desc = "Rename symbol" }) diff --git a/private_dot_config/nvim/lua/config/set.lua b/private_dot_config/nvim/lua/config/set.lua new file mode 100644 index 0000000..f06b4da --- /dev/null +++ b/private_dot_config/nvim/lua/config/set.lua @@ -0,0 +1,34 @@ +-- Colorscheme -- +vim.cmd.colorscheme "catppuccin-latte" +-- Looks -- +vim.opt.relativenumber = true +vim.opt.number = true +vim.opt.signcolumn = 'yes' +vim.opt.cursorline = false +vim.opt.list = true +vim.opt.wrap = false +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.expandtab = true +vim.opt.list = true + +-- Highlight line yank -- +vim.api.nvim_create_augroup("YankHighlight", { clear = true }) +vim.api.nvim_create_autocmd("TextYankPost", { + group = "YankHighlight", + callback = function() + vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 }) + end, +}) + +-- shared clipboard -- +vim.opt.clipboard = "unnamedplus" + +-- Language -- +vim.opt.spell = true +vim.opt.spelllang = { 'pl', 'en' } + +-- Telescope -- +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) +vim.keymap.set('n', 'fg', builtin.git_files, { desc = 'Telescope find git files' }) diff --git a/private_dot_config/nvim/lua/plugins/colorscheme.lua b/private_dot_config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..9b4a8b4 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,5 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000 +} diff --git a/private_dot_config/nvim/lua/plugins/git.lua b/private_dot_config/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..2f322d1 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/git.lua @@ -0,0 +1,119 @@ +return { + "lewis6991/gitsigns.nvim", + + config = function() + require('gitsigns').setup { + signs = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged = { + add = { text = '┃' }, + change = { text = '┃' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + untracked = { text = '┆' }, + }, + signs_staged_enable = true, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + follow_files = true + }, + auto_attach = true, + attach_to_untracked = false, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + virt_text_priority = 100, + use_focus = true, + }, + current_line_blame_formatter = ', - ', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, -- Disable if file is longer than this (in lines) + preview_config = { + -- Options passed to nvim_open_win + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + + on_attach = function(bufnr) + local gitsigns = require('gitsigns') + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal({ ']c', bang = true }) + else + gitsigns.nav_hunk('next') + end + end) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + gitsigns.nav_hunk('prev') + end + end) + + -- Actions + map('n', 'hs', gitsigns.stage_hunk) + map('n', 'hr', gitsigns.reset_hunk) + + map('v', 'hs', function() + gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end) + + map('v', 'hr', function() + gitsigns.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) + end) + + map('n', 'hS', gitsigns.stage_buffer) + map('n', 'hR', gitsigns.reset_buffer) + map('n', 'hp', gitsigns.preview_hunk) + map('n', 'hi', gitsigns.preview_hunk_inline) + + map('n', 'hb', function() + gitsigns.blame_line({ full = true }) + end) + + map('n', 'hd', gitsigns.diffthis) + + map('n', 'hD', function() + gitsigns.diffthis('~') + end) + + map('n', 'hQ', function() gitsigns.setqflist('all') end) + map('n', 'hq', gitsigns.setqflist) + + -- Toggles + map('n', 'tb', gitsigns.toggle_current_line_blame) + map('n', 'tw', gitsigns.toggle_word_diff) + + -- Text object + map({ 'o', 'x' }, 'ih', gitsigns.select_hunk) + end + } + end +} diff --git a/private_dot_config/nvim/lua/plugins/harpoon.lua b/private_dot_config/nvim/lua/plugins/harpoon.lua new file mode 100644 index 0000000..70934d2 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/harpoon.lua @@ -0,0 +1,48 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + init = function() + local harpoon = require("harpoon") + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + vim.keymap.set("n", "a", function() harpoon:list():add() end, { desc = "Add file to harpoon" }) + vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, + { desc = "Toggle harpoon ui" }) + + vim.keymap.set("n", "", function() harpoon:list():select(1) end) + vim.keymap.set("n", "", function() harpoon:list():select(2) end) + vim.keymap.set("n", "", function() harpoon:list():select(3) end) + vim.keymap.set("n", "", function() harpoon:list():select(4) end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set("n", "", function() harpoon:list():prev() end, + { desc = "Toggle next harpoon buffer" }) + vim.keymap.set("n", "", function() harpoon:list():next() end, + { desc = "Toggle previous harpoon buffer" }) + + -- basic telescope configuration + local conf = require("telescope.config").values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require("telescope.pickers").new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() + end + + vim.keymap.set("n", "", function() toggle_telescope(harpoon:list()) end, + { desc = "Open harpoon window" }) + end +} diff --git a/private_dot_config/nvim/lua/plugins/lsp.lua b/private_dot_config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..ec17702 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,115 @@ +return { + 'neovim/nvim-lspconfig', + lazy = false, + dependencies = { + { + "mason-org/mason.nvim", + opts = { + modifiable = true + } + }, + { + "mason-org/mason-lspconfig.nvim", + opts = {}, + }, + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/nvim-cmp', + 'saadparwaiz1/cmp_luasnip', + { "L3MON4D3/LuaSnip", build = "make install_jsregexp" }, + }, + config = function() + local cmp_lsp = require("cmp_nvim_lsp") + local cmp = require("cmp") + local cmp_select = { behavior = cmp.SelectBehavior.Select } + + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, + { + { name = 'buffer' }, + }) + }) + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_lsp.default_capabilities() + ) + vim.diagnostic.config({ + virtual_text = { + prefix = "●", + spacing = 2, + source = "if_many", + }, + signs = true, + underline = true, + update_in_insert = false + }) + + require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + "clangd", + "rust_analyzer" + }, + handlers = { + function(server_name) + require("lspconfig")[server_name].setup({ + capabilities = capabilities, + }) + end + }, + automatic_enable = true, + }) + + local buffer_autoformat = function(bufnr) + local group = 'lsp_autoformat' + vim.api.nvim_create_augroup(group, { clear = false }) + vim.api.nvim_clear_autocmds({ group = group, buffer = bufnr }) + + vim.api.nvim_create_autocmd('BufWritePre', { + buffer = bufnr, + group = group, + desc = "Lsp format on save", + callback = function() + vim.lsp.buf.format({ async = false, timeout_ms = 10000 }) + end + }) + end + + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(event) + local id = vim.tbl_get(event, 'data', 'client_id') + local client = id and vim.lsp.get_client_by_id(id) + + if client == nil then + return + end + + if client.supports_method('textDocument/formatting') then + buffer_autoformat(event.buf) + end + end + }) + end, +} diff --git a/private_dot_config/nvim/lua/plugins/telescope.lua b/private_dot_config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..cab94b6 --- /dev/null +++ b/private_dot_config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,5 @@ +return { + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' } +} diff --git a/private_dot_config/nvim/lua/plugins/whichkey.lua b/private_dot_config/nvim/lua/plugins/whichkey.lua new file mode 100644 index 0000000..9427793 --- /dev/null +++ b/private_dot_config/nvim/lua/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/private_dot_config/nvim/spell/executable_pl.cp1250.spl b/private_dot_config/nvim/spell/executable_pl.cp1250.spl new file mode 100644 index 0000000..30627f4 Binary files /dev/null and b/private_dot_config/nvim/spell/executable_pl.cp1250.spl differ diff --git a/private_dot_config/nvim/spell/executable_pl.iso-8859-2.spl b/private_dot_config/nvim/spell/executable_pl.iso-8859-2.spl new file mode 100644 index 0000000..89b625c Binary files /dev/null and b/private_dot_config/nvim/spell/executable_pl.iso-8859-2.spl differ diff --git a/private_dot_config/nvim/spell/executable_pl.utf-8.spl b/private_dot_config/nvim/spell/executable_pl.utf-8.spl new file mode 100644 index 0000000..17cc61f Binary files /dev/null and b/private_dot_config/nvim/spell/executable_pl.utf-8.spl differ