initial commit

This commit is contained in:
baldeau 2024-09-12 21:43:42 +02:00
commit d6efd67a03
16 changed files with 305 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
lazy-lock.json

17
DEPENDS.md Normal file
View File

@ -0,0 +1,17 @@
# Dependencies
- neovim
- luarocks
- git
- nerd font compatible font
- tree-sitter cli
## Languages
- Dart
- Rust
- Golang
## Formatters
- stylua

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# nvim-config
My tiny neovim config. It's as default and simple as possible, just pure Vim goodness without bloat.
Check `DEPENDS.md` for the dependencies.

4
init.lua Normal file
View File

@ -0,0 +1,4 @@
require("config.lazy")
require("config.remap")
require("main")

35
lua/config/lazy.lua Normal file
View File

@ -0,0 +1,35 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "habamax" } },
-- automatically check for plugin updates
checker = { enabled = false },
})

28
lua/config/remap.lua Normal file
View File

@ -0,0 +1,28 @@
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("n", "<C-b>", ":NvimTreeToggle<CR>", {
noremap = true,
})
vim.keymap.set("n", "<leader>n", ":NvimTreeToggle<CR>", {
noremap = true,
})
vim.keymap.set("n", "<leader>a", ":lua vim.lsp.buf.code_action()<CR>")
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, {})
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
vim.keymap.set("n", "<leader>fb", builtin.buffers, {})
vim.keymap.set("n", "<leader>fh", builtin.help_tags, {})
vim.keymap.set("n", "<leader>pp", "<Cmd>Telescope projects<CR>", {})
function _ADD_CURR_DIR_TO_PROJECTS()
local historyfile = require("project_nvim.utils.path").historyfile
local curr_directory = vim.fn.expand("%:p:h")
vim.cmd("!echo " .. curr_directory .. " >> " .. historyfile)
end
vim.cmd("command! ProjectAddManually lua _ADD_CURR_DIR_TO_PROJECTS()")
vim.keymap.set("n", "<leader>d", ":lua vim.lsp.buf.hover()<CR>")

28
lua/main/init.lua Normal file
View File

@ -0,0 +1,28 @@
vim.opt["tabstop"] = 4
vim.opt["shiftwidth"] = 4
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
rust = { "rustfmt", lsp_format = "fallback" },
javascript = { "prettier", stop_after_first = true },
dart = { "dart format", lsp_format = "fallback" },
go = { "gofmt" },
},
})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*",
callback = function(args)
require("conform").format({ bufnr = args.buf })
end,
})
require("flutter-tools").setup({
dev_log = {
enabled = true,
filter = nil, -- optional callback to filter the log
notify_errors = false, -- notify the user if the is an error whilst running
open_cmd = "tabedit",
},
})

9
lua/plugins/flutter.lua Normal file
View File

@ -0,0 +1,9 @@
return {
"akinsho/flutter-tools.nvim",
lazy = false,
dependencies = {
"nvim-lua/plenary.nvim",
"stevearc/dressing.nvim", -- optional for vim.ui.select
},
config = true,
}

10
lua/plugins/love.lua Normal file
View File

@ -0,0 +1,10 @@
return {
"S1M0N38/love2d.nvim",
cmd = "LoveRun",
opts = {},
keys = {
{ "<leader>v", ft = "lua", desc = "LÖVE" },
{ "<leader>vv", "<cmd>LoveRun<cr>", ft = "lua", desc = "Run LÖVE" },
{ "<leader>vs", "<cmd>LoveStop<cr>", ft = "lua", desc = "Stop LÖVE" },
},
}

72
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,72 @@
return {
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"nvim-lua/plenary.nvim",
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lsp",
{ "antosha417/nvim-lsp-file-operations", config = true },
},
config = function()
-- https://github.com/folke/lazydev.nvim
-- import lspconfig plugin
local lspconfig = require("lspconfig")
-- import cmp-nvim-lsp plugin
local cmp_nvim_lsp = require("cmp_nvim_lsp")
--local keymap = vim.keymap -- for conciseness
local opts = { noremap = true, silent = true }
-- configure dart server (with special settings)
--[[
lspconfig["dartls"].setup({
cmd = { "dart", "language-server", "--protocol=lsp" },
filetypes = { "dart" },
init_options = {
closingLabels = true,
flutterOutline = true,
onlyAnalyzeProjectsWithOpenFiles = true,
outline = true,
suggestFromUnimportedLibraries = true,
},
settings = { -- custom settings for dartls
dart = {
completeFunctionCalls = true,
showTodos = true,
},
},
})
--]]
lspconfig.rust_analyzer.setup({
settings = {
["rust-analyzer"] = {
diagnostics = {
enable = false,
},
},
},
})
lspconfig.gopls.setup({})
lspconfig.lua_ls.setup({})
local cmp = require("cmp")
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<C-a>"] = cmp.mapping.scroll_docs(-4),
["<C-z>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "buffer" },
}),
})
end,
}

10
lua/plugins/prettier.lua Normal file
View File

@ -0,0 +1,10 @@
return {
{
"stevearc/conform.nvim",
opts = {},
},
{
"m4xshen/autoclose.nvim",
opts = {},
},
}

View File

@ -0,0 +1,4 @@
return {
"nvim-telescope/telescope.nvim",
opts = {},
}

18
lua/plugins/themes.lua Normal file
View File

@ -0,0 +1,18 @@
return {
{
"folke/tokyonight.nvim",
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
opts = {
transparent = true,
},
config = function()
require("tokyonight").setup({
cache = false,
transparent = true,
})
-- load the colorscheme here
vim.cmd([[colorscheme tokyonight]])
end,
},
}

View File

@ -0,0 +1,17 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"c",
"markdown",
"dart",
"rust",
"go",
"lua",
"vim",
},
auto_install = true,
},
},
}

47
lua/plugins/ui.lua Normal file
View File

@ -0,0 +1,47 @@
return {
{
"kyazdani42/nvim-tree.lua",
opts = {},
},
{
"kyazdani42/nvim-web-devicons",
opts = {},
},
{
"romgrk/barbar.nvim",
dependencies = {
"lewis6991/gitsigns.nvim", -- OPTIONAL: for git status
"nvim-tree/nvim-web-devicons", -- OPTIONAL: for file icons
},
init = function()
vim.g.barbar_auto_setup = false
end,
opts = {
-- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default:
-- animation = true,
-- insert_at_start = true,
-- …etc.
},
version = "^1.0.0", -- optional: only update when a new 1.x version is released
},
{
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {},
},
{
"ahmedkhalf/project.nvim",
opts = {},
config = function()
require("nvim-tree").setup({
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_root = true,
},
})
require("telescope").load_extension("projects")
end,
},
}