Skip to content

Commit

Permalink
scaffold nvim setup
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxWolf-01 committed Oct 22, 2024
1 parent c591c08 commit 5f65b15
Show file tree
Hide file tree
Showing 37 changed files with 589 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bin
*TODO*
*todo*
secrets
*/**lock.json
1 change: 1 addition & 0 deletions install.conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
~/.ideavimrc: vim/ideavimrc
~/bin: bin
~/.icons: desktop/icons
~/.config/nvim: nvim


- create:
Expand Down
39 changes: 39 additions & 0 deletions nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
vim.g.mapleader = " "

-- Setup package manager
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
local repo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system {
"git",
"clone",
"--filter=blob:none",
repo,
"--branch=stable",
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)

require "options"

require("lazy").setup("plugins", require "lazy")

vim.schedule(function()
vim.filetype.add(require "filetypes")
require "mappings"
end)

-- vim.cmd.colorscheme "catppuccin"

-- Add the mason binary path to the PATH variable, so that plugins, such as
-- conform, can use the mason binaries.
local function configure_mason_path()
local is_windows = vim.fn.has "win32" ~= 0
local sep = is_windows and "\\" or "/"
local delim = is_windows and ";" or ":"
vim.env.PATH = table.concat({ vim.fn.stdpath "data", "mason", "bin" }, sep)
.. delim
.. vim.env.PATH
end
configure_mason_path()
11 changes: 11 additions & 0 deletions nvim/lua/filetypes.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {
extension = {
ebnf = "ebnf",
mdx = "markdown",
},

filename = {
justfile = "just",
},
}

48 changes: 48 additions & 0 deletions nvim/lua/lazy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
return {
defaults = { lazy = true },
-- install = { colorscheme = { "catppuccin" } },

ui = {
icons = {
ft = "",
lazy = "󰂠 ",
loaded = "",
not_loaded = "",
},
},

performance = {
rtp = {
disabled_plugins = {
"2html_plugin",
"tohtml",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
"tutor",
-- "rplugin",
"syntax",
"synmenu",
"optwin",
"compiler",
"bugreport",
"ftplugin",
},
},
},
}

1 change: 1 addition & 0 deletions nvim/lua/lsps/bashls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
1 change: 1 addition & 0 deletions nvim/lua/lsps/biome.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
1 change: 1 addition & 0 deletions nvim/lua/lsps/docker_compose_language_service.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
5 changes: 5 additions & 0 deletions nvim/lua/lsps/elixirls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
cmd = {
vim.fn.stdpath "data" .. "/mason/packages/elixir-ls/language_server.sh",
},
}
1 change: 1 addition & 0 deletions nvim/lua/lsps/gleam.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
1 change: 1 addition & 0 deletions nvim/lua/lsps/golangci_lint_ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
14 changes: 14 additions & 0 deletions nvim/lua/lsps/gopls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
return {
settings = {
gopls = {
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
},
},
env = {
GOEXPERIMENT = "rangefunc",
},
},
}
1 change: 1 addition & 0 deletions nvim/lua/lsps/hls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
1 change: 1 addition & 0 deletions nvim/lua/lsps/html.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
3 changes: 3 additions & 0 deletions nvim/lua/lsps/jdtls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
cmd = { "jdtls" },
}
1 change: 1 addition & 0 deletions nvim/lua/lsps/jsonls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
26 changes: 26 additions & 0 deletions nvim/lua/lsps/lua_ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local rtp = vim.api.nvim_list_runtime_paths()
local library_paths = {
vim.fn.expand "$VIMRUNTIME/lua",
vim.fn.expand "$VIMRUNTIME/lua/vim/lsp",
}
for _, path in ipairs(rtp) do
local lua_path = path .. "/lua"
if vim.fn.isdirectory(lua_path) == 1 then
table.insert(library_paths, lua_path)
end
end

return {
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = library_paths,
maxPreload = 100000,
preloadFileSize = 10000,
},
},
},
}
1 change: 1 addition & 0 deletions nvim/lua/lsps/nil_ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
1 change: 1 addition & 0 deletions nvim/lua/lsps/nixd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
10 changes: 10 additions & 0 deletions nvim/lua/lsps/pyright.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
settings = {
python = {
analysis = {
autoSearchPaths = true,
typeCheckingMode = "basic",
},
},
},
}
20 changes: 20 additions & 0 deletions nvim/lua/lsps/rust_analyzer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
return {
settings = {
["rust-analyzer"] = {
check = {
command = "clippy",
},
diagnostics = {
enable = true,
},
cargo = {
buildScripts = {
enable = true,
},
},
},
},
on_attach = function(_, bufnr)
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end,
}
1 change: 1 addition & 0 deletions nvim/lua/lsps/tailwindcss.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
11 changes: 11 additions & 0 deletions nvim/lua/lsps/ts_ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {
init_options = {
preferences = {
importModuleSpecifierPreference = "non-relative",
},
},

on_attach = function(client, bufnr)
require("twoslash-queries").attach(client, bufnr)
end,
}
1 change: 1 addition & 0 deletions nvim/lua/lsps/zls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return {}
41 changes: 41 additions & 0 deletions nvim/lua/mappings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local map = vim.keymap.set

-- ====================================================================
-- lsp
-- ====================================================================

map("n", "gD", vim.lsp.buf.declaration, { silent = true })
map("n", "gd", vim.lsp.buf.definition, { silent = true })
map("n", "gi", vim.lsp.buf.implementation, { silent = true })
map("n", "gs", vim.lsp.buf.signature_help, { silent = true })
-- TODO see :help vim.lsp.buf<Tab>

-- ====================================================================
-- diagnostic
-- ====================================================================

map("n", "[d", vim.diagnostic.goto_prev, { silent = true })
map("n", "]d", vim.diagnostic.goto_next, { silent = true })
map("n", "gef", vim.diagnostic.open_float, { silent = true })
map("n", "geq", vim.diagnostic.setqflist, { silent = true })

-- ====================================================================
-- oil
-- ====================================================================

map("n", "-", "<CMD>Oil<CR>", { silent = true })

-- ====================================================================
-- telescope
-- ====================================================================

map("n", "<leader>ff", ":Telescope find_files<CR>", { silent = true })
map("n", "<leader>fw", ":Telescope live_grep<CR>", { silent = true })
map("n", "<leader>fb", ":Telescope buffers<CR>", { silent = true })
map("n", "gi", ":Telescope lsp_implementations<CR>", { silent = true })
map("n", "gd", ":Telescope lsp_definitions<CR>", { silent = true })
map("n", "gr", ":Telescope lsp_references<CR>", { silent = true })
map("n", "gl", ":Telescope diagnostics<CR>", { silent = true })

-- https://github.com/lukasl-dev/nixos/blob/master/dots/nvim/lua/mappings.lua

26 changes: 26 additions & 0 deletions nvim/lua/options.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local o = vim.opt

o.colorcolumn = "80"
o.showmode = false

o.number = true
o.relativenumber = true
o.numberwidth = 2
o.ruler = false

o.expandtab = true
o.shiftwidth = 2
o.smartindent = true
o.tabstop = 2
o.softtabstop = 2

o.signcolumn = "yes"
o.splitbelow = true
o.splitright = true
o.timeoutlen = 400
o.undofile = true

o.clipboard = "unnamedplus"
o.cursorline = true
o.cursorlineopt = "number"

73 changes: 73 additions & 0 deletions nvim/lua/plugins/cmp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
return {
{
"hrsh7th/nvim-cmp",

---@module "cmp"
---@return cmp.ConfigSchema
opts = function()
local cmp = require "cmp"

return {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
preselect = cmp.PreselectMode.Item,
window = {
completion = {
scrollbar = false,
border = "rounded",
winhighlight = "Normal:CmpNormal",
},
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert,
select = true,
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "nvim_lua" },
{ name = "path" },
},
}
end,
},

{
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
}

Loading

0 comments on commit 5f65b15

Please sign in to comment.