feat: finished basic setup
This commit is contained in:
parent
01032344ec
commit
409c19fefb
7 changed files with 116 additions and 17 deletions
|
@ -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({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = 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", "<leader>vws", function() vim.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>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", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end)
|
||||
|
||||
lsp.setup()
|
||||
|
|
2
init.lua
2
init.lua
|
@ -1,2 +1,2 @@
|
|||
require("moonleay")
|
||||
print("Welcome to nvim.")
|
||||
print("Welcome to neovim, moonleay.")
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
require("moonleay.remap")
|
||||
require("moonleay.packer")
|
||||
require("moonleay.set")
|
||||
vim.cmd.colorscheme "catppuccin-mocha"
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
{'neovim/nvim-lspconfig'},
|
||||
{'williamboman/mason.nvim'},
|
||||
{'williamboman/mason-lspconfig.nvim'},
|
||||
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'}, -- Required
|
||||
{'hrsh7th/cmp-nvim-lsp'}, -- Required
|
||||
{'L3MON4D3/LuaSnip'}, -- Required
|
||||
{'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)
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
vim.g.mapleader = " "
|
||||
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
|
||||
|
||||
vim.keymap.set("v", "J", ">+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", "<-2<CR>gv=gv")
|
||||
|
|
28
lua/moonleay/set.lua
Normal file
28
lua/moonleay/set.lua
Normal file
|
@ -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 = " "
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue