configure basic lsp snippets
This commit is contained in:
parent
ee3f77ebba
commit
6012671d7e
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
require("options/prose")
|
||||||
|
vim.cmd("colorscheme gruvbox")
|
||||||
|
vim.cmd("PencilSoft")
|
|
@ -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")
|
||||||
|
|
||||||
|
|
|
@ -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" }
|
||||||
|
}
|
|
@ -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", "<leader>+", ":bNext<cr>") --switch tabs
|
||||||
|
map("n", "<leader>n", ":Neotree toggle<cr>") --open Nerdtree
|
||||||
|
map("n", "<leader>z", ":ZenMode<cr>") --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', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
||||||
|
|
||||||
|
-- Jump to the definition
|
||||||
|
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
|
||||||
|
|
||||||
|
-- Jump to declaration
|
||||||
|
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
||||||
|
|
||||||
|
-- Lists all the implementations for the symbol under the cursor
|
||||||
|
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
|
||||||
|
|
||||||
|
-- Jumps to the definition of the type symbol
|
||||||
|
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
||||||
|
|
||||||
|
-- Lists all the references
|
||||||
|
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
|
||||||
|
|
||||||
|
-- Displays a function's signature information
|
||||||
|
bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
|
||||||
|
|
||||||
|
-- Renames all references to the symbol under the cursor
|
||||||
|
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
||||||
|
|
||||||
|
-- Selects a code action available at the current cursor position
|
||||||
|
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
|
||||||
|
|
||||||
|
-- Show diagnostics in a floating window
|
||||||
|
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
|
||||||
|
|
||||||
|
-- Move to the previous diagnostic
|
||||||
|
bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
|
||||||
|
|
||||||
|
-- Move to the next diagnostic
|
||||||
|
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,5 @@
|
||||||
|
vim.opt.wrap = true
|
||||||
|
vim.opt.linebreak = true
|
||||||
|
vim.opt.textwidth = 0 --prevent vim from isnerting linebreaks
|
||||||
|
|
||||||
|
|
|
@ -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 <CurrentMajor> 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",
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
require("bufferline").setup{}
|
|
@ -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 {}
|
|
@ -0,0 +1,8 @@
|
||||||
|
local function getWords()
|
||||||
|
return tostring(vim.fn.wordcount().words)
|
||||||
|
end
|
||||||
|
require('lualine').setup {
|
||||||
|
sections = {
|
||||||
|
lualine_z = { getWords },
|
||||||
|
},
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
require("neo-tree").setup({})
|
|
@ -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 = {
|
||||||
|
['<Up>'] = cmp.mapping.select_prev_item(select_opts),
|
||||||
|
['<Down>'] = cmp.mapping.select_next_item(select_opts),
|
||||||
|
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(select_opts),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(select_opts),
|
||||||
|
|
||||||
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
['<C-y>'] = cmp.mapping.confirm({select = true}),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({select = false}),
|
||||||
|
|
||||||
|
['<C-f>'] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.jumpable(1) then
|
||||||
|
luasnip.jump(1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {'i', 's'}),
|
||||||
|
|
||||||
|
['<C-b>'] = cmp.mapping(function(fallback)
|
||||||
|
if luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {'i', 's'}),
|
||||||
|
|
||||||
|
['<Tab>'] = 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'}),
|
||||||
|
|
||||||
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item(select_opts)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, {'i', 's'}),
|
||||||
|
},
|
||||||
|
})
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue