-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Neovim LSP-related plugins and configurations (#37)
* feat: initial LSP setup: - The lsp.lua file configues main LSP-related plugins: * nvim-lspconfig - basic, default LSP client configurations * mason - LSP, DAP, linter, and formatter package manager * mason-lspconfig - automatically install and configure servers * mason-tool-installer - install and update Mason packages * fidget - LSP status messages - dressing.nvim provides nice menus for vim.ui.select and vim.ui.input which are used to filter Mason packages (it's unusable without this) - lazydev.nvim provides automatic LuaLS configurations for Neovim configuration files - manjaro_packages is updated to add unzip and npm, which are required by Mason * feat: add autoformat Neovim configuration - autoformat.lua configures the Neovim plugin and formatting tools for a few languages - stylua.toml configures the Lua autoformatting project-wide * feat: add autocompletion Neovim configuration * feat: add linting Neovim configuration
- Loading branch information
Showing
9 changed files
with
379 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,7 @@ ctags | |
fd | ||
fzf | ||
neovim | ||
npm | ||
ripgrep | ||
unzip | ||
zsh |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
column_width = 80 | ||
line_endings = "Unix" | ||
indent_type = "Spaces" | ||
indent_width = 2 |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
return { | ||
"stevearc/conform.nvim", | ||
-- Load plugin before writing file, since it will automatically format when | ||
-- writing | ||
event = { "BufWritePre" }, | ||
-- Also load | ||
cmd = { "ConformInfo" }, | ||
init = function() | ||
-- Set formatexpr so builtin vim formatting commands will use conform. | ||
-- This sets the following options automatically: | ||
-- opts = vim.tbl_deep_extend("keep", opts or {}, { | ||
-- timeout_ms = 500, | ||
-- lsp_format = "fallback", | ||
-- bufnr = vim.api.nvim_get_current_buf(), | ||
-- }) | ||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" | ||
end, | ||
opts = { | ||
notify_on_error = false, | ||
format_on_save = function(bufnr) | ||
-- Disable "format_on_save lsp_fallback" for languages that don't have a | ||
-- well standardized coding style. You can add additional languages here | ||
-- or re-enable it for the disabled ones. | ||
local disable_filetypes = { c = true, cpp = true } | ||
local lsp_format_opt | ||
if disable_filetypes[vim.bo[bufnr].filetype] then | ||
lsp_format_opt = "never" | ||
else | ||
lsp_format_opt = "fallback" | ||
end | ||
return { | ||
timeout_ms = 500, | ||
lsp_format = lsp_format_opt, | ||
} | ||
end, | ||
-- Configure formatters per file type. | ||
formatters_by_ft = { | ||
lua = { "stylua" }, | ||
python = { "isort", "black" }, | ||
markdown = { "markdownlint" }, | ||
}, | ||
}, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
return { | ||
"hrsh7th/nvim-cmp", | ||
event = "VimEnter", | ||
dependencies = { | ||
{ | ||
"L3MON4D3/LuaSnip", | ||
build = (function() | ||
return "make install_jsregexp" | ||
end)(), | ||
}, | ||
"saadparwaiz1/cmp_luasnip", | ||
"hrsh7th/cmp-nvim-lsp", | ||
"hrsh7th/cmp-buffer", | ||
"hrsh7th/cmp-path", | ||
}, | ||
config = function() | ||
local cmp = require("cmp") | ||
local luasnip = require("luasnip") | ||
luasnip.config.setup({}) | ||
|
||
cmp.setup({ | ||
snippet = { | ||
expand = function(args) | ||
vim.snippet.expand(args.body) | ||
end, | ||
}, | ||
completion = { | ||
-- Only manual completions, please | ||
autocomplete = false, | ||
completeopt = "menu,menuone,noinsert", | ||
}, | ||
|
||
mapping = cmp.mapping.preset.insert({ | ||
-- Scroll the documentation window [b]ack / [f]orward | ||
["<C-b>"] = cmp.mapping.scroll_docs(-4), | ||
["<C-f>"] = cmp.mapping.scroll_docs(4), | ||
|
||
-- Trigger a completion from nvim-cmp. | ||
["<C-Space>"] = cmp.mapping.complete({}), | ||
|
||
-- Think of <c-l> as moving to the right of your snippet expansion. | ||
-- So if you have a snippet that's like: | ||
-- function $name($args) | ||
-- $body | ||
-- end | ||
-- | ||
-- <c-l> will move you to the right of each of the expansion locations. | ||
-- <c-h> is similar, except moving you backwards. | ||
["<C-l>"] = cmp.mapping(function() | ||
if luasnip.expand_or_locally_jumpable() then | ||
luasnip.expand_or_jump() | ||
end | ||
end, { "i", "s" }), | ||
["<C-h>"] = cmp.mapping(function() | ||
if luasnip.locally_jumpable(-1) then | ||
luasnip.jump(-1) | ||
end | ||
end, { "i", "s" }), | ||
|
||
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, | ||
-- expansion) see: | ||
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps | ||
}), | ||
sources = { | ||
{ | ||
name = "lazydev", | ||
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it | ||
group_index = 0, | ||
}, | ||
{ name = "nvim_lsp" }, | ||
{ name = "buffer" }, | ||
{ name = "path" }, | ||
}, | ||
}) | ||
end, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
return { | ||
"stevearc/dressing.nvim", | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
return { | ||
'folke/lazydev.nvim', | ||
ft = 'lua', | ||
opts = { | ||
library = { | ||
-- Load luvit types when the `vim.uv` word is found | ||
{ path = 'luvit-meta/library', words = { 'vim%.uv' } }, | ||
}, | ||
}, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
return { | ||
{ | ||
"mfussenegger/nvim-lint", | ||
event = { "BufReadPre", "BufNewFile" }, | ||
config = function() | ||
local lint = require("lint") | ||
lint.linters_by_ft = { | ||
dockerfile = { "hadolint" }, | ||
json = { "jsonlint" }, | ||
markdown = { "markdownlint" }, | ||
terraform = { "tflint" }, | ||
} | ||
|
||
-- Create autocommand which carries out the actual linting | ||
-- on the specified events. | ||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) | ||
vim.api.nvim_create_autocmd( | ||
{ "BufEnter", "BufWritePost", "InsertLeave" }, | ||
{ | ||
group = lint_augroup, | ||
callback = function() | ||
-- Only run the linter in buffers that you can modify in order to | ||
-- avoid superfluous noise, notably within the handy LSP pop-ups that | ||
-- describe the hovered symbol using Markdown. | ||
if vim.opt_local.modifiable:get() then | ||
lint.try_lint() | ||
end | ||
end, | ||
} | ||
) | ||
end, | ||
}, | ||
} |
Oops, something went wrong.