-
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.
- Loading branch information
Showing
9 changed files
with
351 additions
and
6 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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
neovim | ||
zsh | ||
base-devel | ||
byobu | ||
ctags | ||
fd | ||
fzf | ||
neovim | ||
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
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,38 @@ | ||
return { | ||
'stevearc/conform.nvim', | ||
event = { 'BufWritePre' }, | ||
cmd = { 'ConformInfo' }, | ||
keys = { | ||
{ | ||
'<leader>f', | ||
function() | ||
require('conform').format { async = true, lsp_format = 'fallback' } | ||
end, | ||
mode = '', | ||
desc = '[F]ormat buffer', | ||
}, | ||
}, | ||
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, | ||
formatters_by_ft = { | ||
lua = { 'stylua' }, | ||
python = { "black" }, | ||
}, | ||
}, | ||
} |
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,75 @@ | ||
return { | ||
"hrsh7th/nvim-cmp", | ||
event = "InsertEnter", | ||
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 = { | ||
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,198 @@ | ||
return { | ||
"neovim/nvim-lspconfig", | ||
dependencies = { | ||
{ "williamboman/mason.nvim", config = true }, | ||
"williamboman/mason-lspconfig.nvim", | ||
"WhoIsSethDaniel/mason-tool-installer.nvim", | ||
{ "j-hui/fidget.nvim", config = true }, | ||
"hrsh7th/cmp-nvim-lsp", | ||
}, | ||
config = function() | ||
-- Create keymaps only when attached to a language server | ||
vim.api.nvim_create_autocmd("LspAttach", { | ||
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }), | ||
desc = "LSP actions", | ||
callback = function(event) | ||
local map = function(keys, func, desc, mode) | ||
mode = mode or "n" | ||
vim.keymap.set(mode, keys, func, { | ||
buffer = event.buf, | ||
desc = "LSP: " .. desc, | ||
}) | ||
end | ||
|
||
-- Jump to the definition of the word under your cursor. | ||
-- This is where a variable was first declared, or where a function is | ||
-- defined, etc. To jump back, press <C-t>. | ||
map( | ||
"gd", | ||
require("telescope.builtin").lsp_definitions, | ||
"[G]oto [D]efinition" | ||
) | ||
|
||
-- Find references for the word under your cursor. | ||
map( | ||
"gr", | ||
require("telescope.builtin").lsp_references, | ||
"[G]oto [R]eferences" | ||
) | ||
|
||
-- Jump to the implementation of the word under your cursor. | ||
-- Useful when your language has ways of declaring types without an | ||
-- actual implementation. | ||
map( | ||
"gI", | ||
require("telescope.builtin").lsp_implementations, | ||
"[G]oto [I]mplementation" | ||
) | ||
|
||
-- Jump to the type of the word under your cursor. | ||
-- Useful when you're not sure what type a variable is and you want to | ||
-- see the definition of its *type*, not where it was *defined*. | ||
map( | ||
"<leader>D", | ||
require("telescope.builtin").lsp_type_definitions, | ||
"Type [D]efinition" | ||
) | ||
|
||
-- Fuzzy find all the symbols in your current document. | ||
-- Symbols are things like variables, functions, types, etc. | ||
map( | ||
"<leader>ds", | ||
require("telescope.builtin").lsp_document_symbols, | ||
"[D]ocument [S]ymbols" | ||
) | ||
|
||
-- Fuzzy find all the symbols in your current workspace. | ||
-- Similar to document symbols, except searches over your entire project. | ||
map( | ||
"<leader>ws", | ||
require("telescope.builtin").lsp_dynamic_workspace_symbols, | ||
"[W]orkspace [S]ymbols" | ||
) | ||
|
||
-- Rename the variable under your cursor. | ||
-- Most Language Servers support renaming across files, etc. | ||
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame") | ||
|
||
-- Execute a code action, usually your cursor needs to be on top of an | ||
-- error or a suggestion from your LSP for this to activate. | ||
map( | ||
"<leader>ca", | ||
vim.lsp.buf.code_action, | ||
"[C]ode [A]ction", | ||
{ "n", "x" } | ||
) | ||
|
||
-- WARN: This is not Goto Definition, this is Goto Declaration. | ||
-- For example, in C this would take you to the header. | ||
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") | ||
|
||
map("K", vim.lsp.buf.hover, "Information in floating window") | ||
map("gs", vim.lsp.buf.signature_help, "[g]oto [s]ignature help") | ||
|
||
-- Highlight references of the word under the cursor when it rests there | ||
-- for a little while, and clear them when the cursor is moved. | ||
local client = vim.lsp.get_client_by_id(event.data.client_id) | ||
|
||
if | ||
client | ||
and client.supports_method( | ||
vim.lsp.protocol.Methods.textDocument_documentHighlight | ||
) | ||
then | ||
local highlight_augroup = | ||
vim.api.nvim_create_augroup("lsp-highlight", { clear = false }) | ||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { | ||
buffer = event.buf, | ||
group = highlight_augroup, | ||
callback = vim.lsp.buf.document_highlight, | ||
}) | ||
|
||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { | ||
buffer = event.buf, | ||
group = highlight_augroup, | ||
callback = vim.lsp.buf.clear_references, | ||
}) | ||
|
||
vim.api.nvim_create_autocmd("LspDetach", { | ||
group = vim.api.nvim_create_augroup("lsp-detach", { clear = true }), | ||
callback = function(event2) | ||
vim.lsp.buf.clear_references() | ||
vim.api.nvim_clear_autocmds({ | ||
group = "lsp-highlight", | ||
buffer = event2.buf, | ||
}) | ||
end, | ||
}) | ||
end | ||
|
||
if | ||
client | ||
and client.supports_method( | ||
vim.lsp.protocol.Methods.textDocument_inlayHint | ||
) | ||
then | ||
map("<leader>th", function() | ||
vim.lsp.inlay_hint.enable( | ||
not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }) | ||
) | ||
end, "[T]oggle Inlay [H]ints") | ||
end | ||
end, | ||
}) | ||
|
||
local capabilities = vim.lsp.protocol.make_client_capabilities() | ||
capabilities = vim.tbl_deep_extend( | ||
"force", | ||
capabilities, | ||
require("cmp_nvim_lsp").default_capabilities() | ||
) | ||
|
||
local servers = { | ||
lua_ls = { | ||
settings = { | ||
Lua = { | ||
completion = { | ||
callSnippet = "Replace", | ||
}, | ||
}, | ||
}, | ||
}, | ||
pylsp = {}, | ||
} | ||
|
||
require("mason").setup({ | ||
log_level = vim.log.levels.DEBUG, | ||
}) | ||
|
||
local ensure_installed = vim.tbl_keys(servers or {}) | ||
vim.list_extend(ensure_installed, { | ||
"stylua", | ||
"black", | ||
"flake8", | ||
}) | ||
|
||
require("mason-tool-installer").setup({ | ||
ensure_installed = ensure_installed, | ||
}) | ||
|
||
require("mason-lspconfig").setup({ | ||
handlers = { | ||
function(server_name) | ||
local server = servers[server_name] or {} | ||
-- This handles overriding only values explicitly passed by the server | ||
-- configuration above. Useful when disabling certain features of an | ||
-- LSP (for example, turning off formatting for ts_ls) | ||
server.capabilities = vim.tbl_deep_extend( | ||
"force", | ||
{}, | ||
capabilities, | ||
server.capabilities or {} | ||
) | ||
require("lspconfig")[server_name].setup(server) | ||
end, | ||
}, | ||
}) | ||
end, | ||
} |