commit d6efd67a03c5c9b2677526467e98885e83ffa0d3 Author: baldeau Date: Thu Sep 12 21:43:42 2024 +0200 initial commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..ea88f75 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/DEPENDS.md b/DEPENDS.md new file mode 100644 index 0000000..18fd31c --- /dev/null +++ b/DEPENDS.md @@ -0,0 +1,17 @@ +# Dependencies + +- neovim +- luarocks +- git +- nerd font compatible font +- tree-sitter cli + +## Languages + +- Dart +- Rust +- Golang + +## Formatters + +- stylua diff --git a/README.md b/README.md new file mode 100644 index 0000000..9aaa003 --- /dev/null +++ b/README.md @@ -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. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..1fc22bb --- /dev/null +++ b/init.lua @@ -0,0 +1,4 @@ +require("config.lazy") +require("config.remap") + +require("main") diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..0b93d4e --- /dev/null +++ b/lua/config/lazy.lua @@ -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 }, +}) diff --git a/lua/config/remap.lua b/lua/config/remap.lua new file mode 100644 index 0000000..c58b1ad --- /dev/null +++ b/lua/config/remap.lua @@ -0,0 +1,28 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) + +vim.keymap.set("n", "", ":NvimTreeToggle", { + noremap = true, +}) +vim.keymap.set("n", "n", ":NvimTreeToggle", { + noremap = true, +}) +vim.keymap.set("n", "a", ":lua vim.lsp.buf.code_action()") + +local builtin = require("telescope.builtin") +vim.keymap.set("n", "ff", builtin.find_files, {}) +vim.keymap.set("n", "fg", builtin.live_grep, {}) +vim.keymap.set("n", "fb", builtin.buffers, {}) +vim.keymap.set("n", "fh", builtin.help_tags, {}) + +vim.keymap.set("n", "pp", "Telescope projects", {}) + +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", "d", ":lua vim.lsp.buf.hover()") diff --git a/lua/main/init.lua b/lua/main/init.lua new file mode 100644 index 0000000..b4baf3e --- /dev/null +++ b/lua/main/init.lua @@ -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", + }, +}) diff --git a/lua/plugins/flutter.lua b/lua/plugins/flutter.lua new file mode 100644 index 0000000..f728d04 --- /dev/null +++ b/lua/plugins/flutter.lua @@ -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, +} diff --git a/lua/plugins/love.lua b/lua/plugins/love.lua new file mode 100644 index 0000000..c21ac86 --- /dev/null +++ b/lua/plugins/love.lua @@ -0,0 +1,10 @@ +return { + "S1M0N38/love2d.nvim", + cmd = "LoveRun", + opts = {}, + keys = { + { "v", ft = "lua", desc = "LÖVE" }, + { "vv", "LoveRun", ft = "lua", desc = "Run LÖVE" }, + { "vs", "LoveStop", ft = "lua", desc = "Stop LÖVE" }, + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..0950b35 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -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({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "buffer" }, + }), + }) + end, +} diff --git a/lua/plugins/prettier.lua b/lua/plugins/prettier.lua new file mode 100644 index 0000000..4d6633f --- /dev/null +++ b/lua/plugins/prettier.lua @@ -0,0 +1,10 @@ +return { + { + "stevearc/conform.nvim", + opts = {}, + }, + { + "m4xshen/autoclose.nvim", + opts = {}, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..bb6af72 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,4 @@ +return { + "nvim-telescope/telescope.nvim", + opts = {}, +} diff --git a/lua/plugins/themes.lua b/lua/plugins/themes.lua new file mode 100644 index 0000000..075b939 --- /dev/null +++ b/lua/plugins/themes.lua @@ -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, + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..2d2e368 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,17 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "c", + "markdown", + "dart", + "rust", + "go", + "lua", + "vim", + }, + auto_install = true, + }, + }, +} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua new file mode 100644 index 0000000..3346bd2 --- /dev/null +++ b/lua/plugins/ui.lua @@ -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, + }, +}