diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua new file mode 100644 index 0000000..5f7a65e --- /dev/null +++ b/after/ftplugin/markdown.lua @@ -0,0 +1,4 @@ + +require("options/prose") +vim.cmd("colorscheme gruvbox") +vim.cmd("PencilSoft") diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..6d51fbe --- /dev/null +++ b/init.lua @@ -0,0 +1,26 @@ +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) + +require("options") +require("keymaps") +require("lazy").setup("plugins") +require("luasnip.loaders.from_vscode").lazy_load() +vim.cmd "colorscheme rose-pine" + + +require("setup/lualine") +require("setup/bufferline") +require("setup/nvim-cmp") +require("setup/lsp") + + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..833c5ef --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,26 @@ +{ + "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, + "bufferline.nvim": { "branch": "main", "commit": "64e2c5def50dfd6b6f14d96a45fa3d815a4a1eef" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, + "gruvbox.nvim": { "branch": "main", "commit": "6e4027ae957cddf7b193adfaec4a8f9e03b4555f" }, + "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, + "lualine.nvim": { "branch": "master", "commit": "8b56462bfb746760465264de41b4907310f113ec" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "55716a879568a498fa236593c8119789054a3b8e" }, + "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "7f2ebdef3b55374390714ac7c0a7fe6b0dae498a" }, + "nui.nvim": { "branch": "main", "commit": "756c59f46057cd2d43619cd3a6d4e01b2aa60295" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-lspconfig": { "branch": "master", "commit": "1917b562a02f20885900b1da0f0ea25028ccedab" }, + "nvim-web-devicons": { "branch": "master", "commit": "75df79feb02d5e0ec114e447453775d4d291ea03" }, + "plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" }, + "rose-pine": { "branch": "main", "commit": "a29b09d15a9ef5cd575fbe5ae2a3cfb854876caf" }, + "twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" }, + "vim-pencil": { "branch": "master", "commit": "6d70438a8886eaf933c38a7a43a61adb0a7815ed" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, + "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } +} \ No newline at end of file diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..df198b8 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,64 @@ +function map(mode, lhs, rhs, opts) + local options = { noremap = true, silent = true } + if opts then + options = vim.tbl_extend("force", options, opts) + end + vim.keymap.set(mode, lhs, rhs, options) +end +--This code just maps vim.keymap.set() to something easier to type. Also, typing { noremap = true, silent = true } won’t be needed, because that is also implemented in the function. + +vim.g.mapleader = " " + +map("n", "+", ":bNext") --switch tabs +map("n", "n", ":Neotree toggle") --open Nerdtree +map("n", "z", ":ZenMode") --open ZenMode (distraction-free) + + + + +vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP actions', + callback = function() + local bufmap = function(mode, lhs, rhs) + local opts = {buffer = true} + vim.keymap.set(mode, lhs, rhs, opts) + end + + -- Displays hover information about the symbol under the cursor + bufmap('n', 'K', 'lua vim.lsp.buf.hover()') + + -- Jump to the definition + bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') + + -- Jump to declaration + bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') + + -- Lists all the implementations for the symbol under the cursor + bufmap('n', 'gi', 'lua vim.lsp.buf.implementation()') + + -- Jumps to the definition of the type symbol + bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') + + -- Lists all the references + bufmap('n', 'gr', 'lua vim.lsp.buf.references()') + + -- Displays a function's signature information + bufmap('n', 'gs', 'lua vim.lsp.buf.signature_help()') + + -- Renames all references to the symbol under the cursor + bufmap('n', '', 'lua vim.lsp.buf.rename()') + + -- Selects a code action available at the current cursor position + bufmap('n', '', 'lua vim.lsp.buf.code_action()') + + -- Show diagnostics in a floating window + bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') + + -- Move to the previous diagnostic + bufmap('n', '[d', 'lua vim.diagnostic.goto_prev()') + + -- Move to the next diagnostic + bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') + end +}) + diff --git a/lua/options.lua b/lua/options.lua new file mode 100644 index 0000000..633d487 --- /dev/null +++ b/lua/options.lua @@ -0,0 +1,7 @@ +vim.opt.termguicolors = true +vim.opt.encoding = "utf-8" +vim.opt.autowriteall = true + +vim.opt.undodir = "~/.vim/undodir" +vim.opt.undofile = true +vim.opt.undolevels = 1000 diff --git a/lua/options/prose.lua b/lua/options/prose.lua new file mode 100644 index 0000000..90b1a27 --- /dev/null +++ b/lua/options/prose.lua @@ -0,0 +1,5 @@ +vim.opt.wrap = true +vim.opt.linebreak = true +vim.opt.textwidth = 0 --prevent vim from isnerting linebreaks + + diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..fc6b41d --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,62 @@ +return { +-- {"nvim-treesitter/nvim-treesitter"}, + {"rose-pine/neovim", name = "rose-pine"}, + { "ellisonleao/gruvbox.nvim", priority = 1000 , config = true, opts = ...}, + {"nvim-lualine/lualine.nvim", dependencies = { + "nvim-tree/nvim-web-devicons", + } + }, + {"folke/zen-mode.nvim", + opts = { + window = {width = 60}} + }, + {"folke/twilight.nvim", opts = {context = 1}}, + {"preservim/vim-pencil"}, + {"nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + } + }, + {'akinsho/bufferline.nvim', version = "*", dependencies = 'nvim-tree/nvim-web-devicons'}, + {"folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + }, + --################################################## + --## LANGUAGE SERVER CONFIGS + --################################################## + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", + --################################################# + --## AUTOCOMPLETION/SNIPPETS + --################################################# + "hrsh7th/nvim-cmp", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + {"L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace by the latest released major (first number of latest release) + -- install jsregexp (optional!). + build = "make install_jsregexp", + dependencies = { "rafamadriz/friendly-snippets" }, + }, + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + +} + diff --git a/lua/setup/bufferline.lua b/lua/setup/bufferline.lua new file mode 100644 index 0000000..1c295dc --- /dev/null +++ b/lua/setup/bufferline.lua @@ -0,0 +1 @@ +require("bufferline").setup{} diff --git a/lua/setup/lsp.lua b/lua/setup/lsp.lua new file mode 100644 index 0000000..f30cbfd --- /dev/null +++ b/lua/setup/lsp.lua @@ -0,0 +1,17 @@ +local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() +local lspconfig = require('lspconfig') +require("mason").setup() +require("mason-lspconfig").setup() +lspconfig.lua_ls.setup { + capabilities = lsp_capabilities, +} +lspconfig.grammarly.setup { + filetypes = { "markdown", "tex", "text", }, + init_options = { + clientId = "client_" + }, + root_dir = function(fname) + return require'lspconfig'.util.find_git_ancestor(fname) or vim.loop.os_homedir() + end, +} +require("lspconfig").marksman.setup {} diff --git a/lua/setup/lualine.lua b/lua/setup/lualine.lua new file mode 100644 index 0000000..872e28a --- /dev/null +++ b/lua/setup/lualine.lua @@ -0,0 +1,8 @@ +local function getWords() + return tostring(vim.fn.wordcount().words) +end +require('lualine').setup { + sections = { + lualine_z = { getWords }, + }, +} diff --git a/lua/setup/neotree.lua b/lua/setup/neotree.lua new file mode 100644 index 0000000..4d77c58 --- /dev/null +++ b/lua/setup/neotree.lua @@ -0,0 +1,2 @@ + +require("neo-tree").setup({}) diff --git a/lua/setup/nvim-cmp.lua b/lua/setup/nvim-cmp.lua new file mode 100644 index 0000000..62d95c6 --- /dev/null +++ b/lua/setup/nvim-cmp.lua @@ -0,0 +1,85 @@ +vim.opt.completeopt = {'menu', 'menuone', 'noselect'} +local cmp = require('cmp') +local luasnip = require('luasnip') +local select_opts = {behavior = cmp.SelectBehavior.Select} + +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + sources = { + {name = 'path'}, + {name = 'nvim_lsp', keyword_length = 1}, + {name = 'buffer', keyword_length = 3}, + {name = 'luasnip', keyword_length = 2}, + }, + window = { + documentation = cmp.config.window.bordered() + }, + formatting = { + fields = {'menu', 'abbr', 'kind'}, + format = function(entry, item) + local menu_icon = { + nvim_lsp = 'λ', + luasnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + + item.menu = menu_icon[entry.source.name] + return item + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(select_opts), + [''] = cmp.mapping.select_next_item(select_opts), + + [''] = cmp.mapping.select_prev_item(select_opts), + [''] = cmp.mapping.select_next_item(select_opts), + + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({select = true}), + [''] = cmp.mapping.confirm({select = false}), + + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, {'i', 's'}), + + [''] = cmp.mapping(function(fallback) + if luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, {'i', 's'}), + + [''] = cmp.mapping(function(fallback) + local col = vim.fn.col('.') - 1 + + if cmp.visible() then + cmp.select_next_item(select_opts) + elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + fallback() + else + cmp.complete() + end + end, {'i', 's'}), + + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item(select_opts) + else + fallback() + end + end, {'i', 's'}), + }, +}) diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%after%ftplugin%markdown.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%after%ftplugin%markdown.lua new file mode 100644 index 0000000..3564760 Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%after%ftplugin%markdown.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%init.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%init.lua new file mode 100644 index 0000000..fd101a4 Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%init.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%autocommands.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%autocommands.lua new file mode 100644 index 0000000..73533a8 Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%autocommands.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%config%lsp.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%config%lsp.lua new file mode 100644 index 0000000..1255819 Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%config%lsp.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%keymaps.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%keymaps.lua new file mode 100644 index 0000000..c2cbb5d Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%keymaps.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%options%prose.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%options%prose.lua new file mode 100644 index 0000000..37042ff Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%options%prose.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%options.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%options.lua new file mode 100644 index 0000000..f9771ef Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%options.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%plugins.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%plugins.lua new file mode 100644 index 0000000..4c2830d Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%plugins.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%bufferline.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%bufferline.lua new file mode 100644 index 0000000..c793af3 Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%bufferline.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%lualine.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%lualine.lua new file mode 100644 index 0000000..3998f0d Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%lualine.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%neotree.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%neotree.lua new file mode 100644 index 0000000..33d2c9c Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%neotree.lua differ diff --git a/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%nvim-cmp.lua b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%nvim-cmp.lua new file mode 100644 index 0000000..9977f55 Binary files /dev/null and b/~/.vim/undodir/%home%andrzej%.config%nvim%lua%setup%nvim-cmp.lua differ