diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 0668998..04e432c 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -1,4 +1,44 @@ local lsp = require('lsp-zero') lsp.preset('recommended') + +lsp.ensure_installed({ + 'tsserver', + 'eslint', + 'kotlin_language_server', + 'rust_analyzer', +}) + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} +local cmp_mappings = lsp.defaults.cmp_mappings({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), +}) + +lsp.set_preferences({ + sign_icons = {} +}) + +lsp.setup_nvim_cmp({ + mapping = cmp_mappings +}) + +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.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.openfloat() 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() diff --git a/init.lua b/init.lua index bc13cf1..d9cc765 100644 --- a/init.lua +++ b/init.lua @@ -1,2 +1,2 @@ require("moonleay") -print("Welcome to nvim.") +print("Welcome to neovim, moonleay.") diff --git a/lua/moonleay/init.lua b/lua/moonleay/init.lua index d051f63..b1a2db7 100644 --- a/lua/moonleay/init.lua +++ b/lua/moonleay/init.lua @@ -1,3 +1,6 @@ require("moonleay.remap") require("moonleay.packer") +require("moonleay.set") vim.cmd.colorscheme "catppuccin-mocha" + + diff --git a/lua/moonleay/packer.lua b/lua/moonleay/packer.lua index 1c50d7d..45dc4ed 100644 --- a/lua/moonleay/packer.lua +++ b/lua/moonleay/packer.lua @@ -19,22 +19,23 @@ return require('packer').startup(function(use) use 'tpope/vim-fugitive' use { 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', requires = { - -- LSP Support - {'neovim/nvim-lspconfig'}, -- Required - { -- Optional - 'williamboman/mason.nvim', - run = function() - pcall(vim.cmd, 'MasonUpdate') - end, - }, - {'williamboman/mason-lspconfig.nvim'}, -- Optional + -- LSP Support + {'neovim/nvim-lspconfig'}, + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, - -- Autocompletion - {'hrsh7th/nvim-cmp'}, -- Required - {'hrsh7th/cmp-nvim-lsp'}, -- Required - {'L3MON4D3/LuaSnip'}, -- Required + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'saadparwaiz1/cmp_luasnip'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-nvim-lua'}, + + -- Snippets + {'L3MON4D3/LuaSnip'}, + {'rafamadriz/friendly-snippets'}, + } } -} end) diff --git a/lua/moonleay/remap.lua b/lua/moonleay/remap.lua index b760350..213dce0 100644 --- a/lua/moonleay/remap.lua +++ b/lua/moonleay/remap.lua @@ -1,2 +1,4 @@ -vim.g.mapleader = " " vim.keymap.set("n", "pv", vim.cmd.Ex) + +vim.keymap.set("v", "J", ">+1gv=gv") +vim.keymap.set("v", "K", "<-2gv=gv") diff --git a/lua/moonleay/set.lua b/lua/moonleay/set.lua new file mode 100644 index 0000000..0cdd642 --- /dev/null +++ b/lua/moonleay/set.lua @@ -0,0 +1,28 @@ +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.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" + + +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" + +vim.g.mapleader = " " diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua index 688ec25..593847c 100644 --- a/plugin/packer_compiled.lua +++ b/plugin/packer_compiled.lua @@ -84,11 +84,36 @@ _G.packer_plugins = { path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/catppuccin", url = "https://github.com/catppuccin/nvim" }, + ["cmp-buffer"] = { + loaded = true, + path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/cmp-buffer", + url = "https://github.com/hrsh7th/cmp-buffer" + }, ["cmp-nvim-lsp"] = { loaded = true, path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", url = "https://github.com/hrsh7th/cmp-nvim-lsp" }, + ["cmp-nvim-lua"] = { + loaded = true, + path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua", + url = "https://github.com/hrsh7th/cmp-nvim-lua" + }, + ["cmp-path"] = { + loaded = true, + path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/cmp-path", + url = "https://github.com/hrsh7th/cmp-path" + }, + cmp_luasnip = { + loaded = true, + path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/cmp_luasnip", + url = "https://github.com/saadparwaiz1/cmp_luasnip" + }, + ["friendly-snippets"] = { + loaded = true, + path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/friendly-snippets", + url = "https://github.com/rafamadriz/friendly-snippets" + }, ["lsp-zero.nvim"] = { loaded = true, path = "/home/moonleay/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim",