-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
227 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
-- Bootstrap lazy.nvim if it's not installed. | ||
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", | ||
lazypath | ||
} | ||
vim.fn.system { | ||
"git", | ||
"clone", | ||
"--filter=blob:none", | ||
"https://github.com/folke/lazy.nvim.git", | ||
"--branch=stable", | ||
lazypath | ||
} | ||
end | ||
vim.opt.runtimepath:prepend(lazypath) | ||
|
||
require("lazy").setup({ | ||
lazy = true, | ||
-- Set up all plugins in the lua/plugins directory. | ||
{ import = "plugins" }, | ||
{ import = "plugins.lsp" }, | ||
{ import = "plugins.ui" } | ||
lazy = true, | ||
-- Set up all plugins in the lua/plugins directory. | ||
{ import = "plugins" }, | ||
{ import = "plugins.lsp" }, | ||
{ import = "plugins.ui" } | ||
}) | ||
|
||
require("lsp-setup") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,104 @@ | ||
local map = vim.keymap.set | ||
|
||
-- Language servers: | ||
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() | ||
|
||
local lspconfig = require("lspconfig") | ||
|
||
local default_lsp_setup = function(server) | ||
lspconfig[server].setup({ | ||
capabilities = lsp_capabilities | ||
}) | ||
lspconfig[server].setup({ | ||
capabilities = lsp_capabilities | ||
}) | ||
end | ||
|
||
-- Setup language servers. | ||
-- Choose LSPs. | ||
lspconfig.clangd.setup({}) | ||
lspconfig.gopls.setup({}) | ||
|
||
-- Mason package manager for LSPs, formatters, and linters | ||
require("mason").setup() | ||
require("mason-lspconfig").setup({ | ||
handlers = { default_lsp_setup } | ||
handlers = { default_lsp_setup } | ||
}) | ||
|
||
vim.keymap.set("n", "<Leader>e", vim.diagnostic.open_float) | ||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) | ||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next) | ||
-- LSP keybindings. | ||
map("n", "<Leader>e", vim.diagnostic.open_float) | ||
map("n", "[d", vim.diagnostic.goto_prev) | ||
map("n", "]d", vim.diagnostic.goto_next) | ||
|
||
-- Use LspAttach autocommand to only map the following keys after the language | ||
-- server attaches to the current buffer. | ||
vim.api.nvim_create_autocmd("LspAttach", { group = | ||
vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) | ||
local opts = { buffer = ev.buf } | ||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) | ||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) | ||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) | ||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts) | ||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts) | ||
vim.keymap.set("n", "<Leader>D", vim.lsp.buf.type_definition, opts) | ||
vim.keymap.set("n", "<Leader>rn", vim.lsp.buf.rename, opts) | ||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) | ||
vim.keymap.set("n", "<Leader>f", function() | ||
vim.lsp.buf.format { async = true } | ||
end, opts) | ||
end, | ||
vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) | ||
local opts = { buffer = ev.buf } | ||
|
||
map("n", "gD", vim.lsp.buf.declaration, opts) | ||
map("n", "gd", vim.lsp.buf.definition, opts) | ||
map("n", "K", vim.lsp.buf.hover, opts) | ||
map("n", "gi", vim.lsp.buf.implementation, opts) | ||
map("n", "<C-k>", vim.lsp.buf.signature_help, opts) | ||
map("n", "<Leader>D", vim.lsp.buf.type_definition, opts) | ||
map("n", "<Leader>rn", vim.lsp.buf.rename, opts) | ||
map("n", "gr", vim.lsp.buf.references, opts) | ||
map("n", "<Leader>f", function() | ||
vim.lsp.buf.format { async = true } | ||
end, opts) | ||
end | ||
}) | ||
|
||
-------------------------------------------------------------------------------- | ||
-- Autocompletion | ||
-- Helper function. | ||
local has_words_before = function() | ||
unpack = unpack or table.unpack | ||
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) | ||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil | ||
unpack = unpack or table.unpack | ||
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) | ||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil | ||
end | ||
|
||
-- Setup autocompletion. | ||
local cmp = require("cmp") | ||
|
||
cmp.setup({ | ||
sources = { | ||
{ name = "nvim_lsp" }, | ||
{ name = "buffer" }, | ||
{ name = "path" } | ||
}, | ||
mapping = cmp.mapping.preset.insert({ | ||
-- Enter key confirms completion item. | ||
["<CR>"] = cmp.mapping(function(fallback) | ||
-- This little snippet will confirm with <CR>, and if no entry is | ||
-- selected, will confirm the first item. | ||
if cmp.visible() then | ||
local entry = cmp.get_selected_entry() | ||
if not entry then | ||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) | ||
end | ||
cmp.confirm() | ||
else | ||
fallback() | ||
end | ||
end, {"i","s","c",}), | ||
sources = { | ||
{name = "nvim_lsp"}, | ||
{name = "buffer"}, | ||
{name = "path"} | ||
}, | ||
mapping = cmp.mapping.preset.insert({ | ||
-- Enter key confirms completion item. | ||
["<CR>"] = cmp.mapping(function(fallback) | ||
-- This little snippet will confirm with <CR>, and if no entry is | ||
-- selected, will confirm the first item. | ||
if cmp.visible() then | ||
local entry = cmp.get_selected_entry() | ||
if not entry then | ||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) | ||
end | ||
cmp.confirm() | ||
else | ||
fallback() | ||
end | ||
end, {"i","s","c"}), | ||
|
||
-- Use <Tab>/<S-Tab> to cycle selections. | ||
["<Tab>"] = cmp.mapping(function(fallback) | ||
if cmp.visible() then | ||
cmp.select_next_item() | ||
elseif has_words_before() then | ||
cmp.complete() | ||
else | ||
fallback() | ||
end | ||
end, { "i", "s" }), | ||
-- Use <Tab>/<S-Tab> to cycle selections. | ||
["<Tab>"] = cmp.mapping(function(fallback) | ||
if cmp.visible() then | ||
cmp.select_next_item() | ||
elseif has_words_before() then | ||
cmp.complete() | ||
else | ||
fallback() | ||
end | ||
end, {"i", "s"}), | ||
|
||
["<S-Tab>"] = cmp.mapping(function(fallback) | ||
if cmp.visible() then | ||
cmp.select_prev_item() | ||
else | ||
fallback() | ||
end | ||
end, { "i", "s" }), | ||
["<S-Tab>"] = cmp.mapping(function(fallback) | ||
if cmp.visible() then | ||
cmp.select_prev_item() | ||
else | ||
fallback() | ||
end | ||
end, {"i", "s"}), | ||
|
||
-- Ctrl + space triggers completion menu. | ||
["<C-Space>"] = cmp.mapping.complete(), | ||
}), | ||
-- Ctrl + space triggers completion menu. | ||
["<C-Space>"] = cmp.mapping.complete(), | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
-- Insert or delete brackets, parenthesis, quotes in pairs. | ||
return { | ||
"jiangmiao/auto-pairs" | ||
"jiangmiao/auto-pairs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
return { | ||
"williamboman/mason.nvim", | ||
"williamboman/mason-lspconfig.nvim" | ||
"williamboman/mason.nvim", | ||
"williamboman/mason-lspconfig.nvim" | ||
} |
Oops, something went wrong.