commit 970a7c22e167ee424f059170c16af79775b88496 Author: ant Date: Fri Aug 11 21:22:09 2023 +0200 initial commit 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/init.lua b/init.lua new file mode 100644 index 0000000..c3c6d34 --- /dev/null +++ b/init.lua @@ -0,0 +1,54 @@ +-- lua configuratiuon file for neovim + +local opt = vim.opt +local g = vim.g + +opt.clipboard = "unnamedplus" +opt.cursorline = true +opt.showmode = false + +-- Indenting +opt.expandtab = true +opt.shiftwidth = 2 +opt.smartindent = true +opt.tabstop = 2 +opt.softtabstop = 2 + +opt.fillchars = { eob = " " } +opt.ignorecase = true +opt.smartcase = true +opt.mouse = "a" + +-- Numbers +opt.number = true +opt.numberwidth = 2 +opt.ruler = false + +opt.signcolumn = "yes" +opt.splitbelow = true +opt.splitright = true +opt.termguicolors = true +opt.timeoutlen = 300 +opt.undofile = true + + +g.mapleader = "," +-- opt.fillchars = { eob = "~" } +opt.scrolloff = 4 +opt.spelllang = "fr" +opt.colorcolumn = {100} +opt.textwidth = 100 +opt.timeoutlen = 1000 +opt.breakindent = true + + + +require("bootstrap") + +local plugins = require("plugins") +require("lazy").setup(plugins) + +vim.cmd.colorscheme "catppuccin" +opt.background = "dark" + +require("mappings") diff --git a/lua/bootstrap.lua b/lua/bootstrap.lua new file mode 100644 index 0000000..9fad236 --- /dev/null +++ b/lua/bootstrap.lua @@ -0,0 +1,13 @@ +-- bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) diff --git a/lua/configs/cmp.lua b/lua/configs/cmp.lua new file mode 100644 index 0000000..796ee54 --- /dev/null +++ b/lua/configs/cmp.lua @@ -0,0 +1,33 @@ +local cmp = require "cmp" + +local options = { + completion = { + completeopt = 'menu,menuone,noinsert,noselect' + }, + + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + [""] = function(callback) + callback() + end, + [""] = function(callback) + callback() + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "path" }, + }, +} + +return options diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua new file mode 100644 index 0000000..e01e8b1 --- /dev/null +++ b/lua/configs/lspconfig.lua @@ -0,0 +1,34 @@ +require("mason-lspconfig").setup_handlers { + -- The first entry (without a key) will be the default handler + -- and will be called for each installed server that doesn't have + -- a dedicated handler. + function (server_name) -- default handler (optional) + require("lspconfig")[server_name].setup {} + end, + -- Next, you can provide a dedicated handler for specific servers. + -- For example, a handler override for the `rust_analyzer`: + -- ["rust_analyzer"] = function () + -- require("rust-tools").setup {} + -- end + ["lua_ls"] = function () + require("lspconfig").lua_ls.setup { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand "$VIMRUNTIME/lua"] = true, + [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true, + [vim.fn.stdpath "data" .. "/lazy/extensions/nvchad_types"] = true, + [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true, + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + }, + }, + } + end +} diff --git a/lua/configs/lualine.lua b/lua/configs/lualine.lua new file mode 100644 index 0000000..ec8ecfb --- /dev/null +++ b/lua/configs/lualine.lua @@ -0,0 +1,41 @@ +local opts = { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff' }, + lualine_c = { 'filename' }, + lualine_x = { 'lsp_progress', 'diagnostics', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} +return opts diff --git a/lua/mappings.lua b/lua/mappings.lua new file mode 100644 index 0000000..0ec2390 --- /dev/null +++ b/lua/mappings.lua @@ -0,0 +1,73 @@ +vim.keymap.set("i", "", "", { desc = "Move left" }) +vim.keymap.set("i", "", "", { desc = "Move right" }) +vim.keymap.set("i", "", "", { desc = "Move down" }) +vim.keymap.set("i", "", "", { desc = "Move up" }) +vim.keymap.set("n", "", ":noh", { desc = "Clear highlights" }) +vim.keymap.set("n", "b", " enew ", { desc = "New buffer" }) +vim.keymap.set("n", "x", " bdelete ", { desc = "Delete buffer" }) +vim.keymap.set("n", "", " bn ", { desc = "Next buffer" }) +vim.keymap.set("n", "", " bp ", { desc = "Previous buffer" }) +vim.keymap.set("n", "ZZ", " q! ", { desc = "Quit without saving" }) +vim.keymap.set('n', 'H', require('treesj').toggle) +vim.keymap.set( + 'n', + 'ff', + " Telescope find_files follow=true no_ignore=true hidden=true " +) +vim.keymap.set('n', 'ft', MiniFiles.open, { desc = "Open file tree" }) + + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) + vim.keymap.set('n', '[[', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', ']]', vim.diagnostic.goto_next, opts) + vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'ra', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'fm', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +}) + +-- Descriptions for lspconfig mappings +local wk = require("which-key") +wk.register({ + ["e"] = { vim.diagnostic.open_float, "Show diagnostics" }, + ["[["] = { vim.diagnostic.goto_prev, "Previous diagnostic" }, + ["]]"] = { vim.diagnostic.goto_next, "Next diagnostic" }, + ["q"] = { vim.diagnostic.setloclist, "Set location list" }, + ["gD"] = { vim.lsp.buf.declaration, "Goto declaration" }, + ["gd"] = { vim.lsp.buf.definition, "Goto definition" }, + ["K"] = { vim.lsp.buf.hover, "Hover" }, + ["gi"] = { vim.lsp.buf.implementation, "Goto implementation" }, + [""] = { vim.lsp.buf.signature_help, "Signature help" }, + ["D"] = { vim.lsp.buf.type_definition, "Goto type definition" }, + ["ra"] = { vim.lsp.buf.rename, "Rename" }, + ["ca"] = { vim.lsp.buf.code_action, "Code action" }, + ["gr"] = { vim.lsp.buf.references, "Goto references" }, + ["fm"] = { function() + vim.lsp.buf.format { async = true } + end, "Format" }, + +}) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..27f9531 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,228 @@ +local plugins = { + { + 'nvim-treesitter/nvim-treesitter', + config = function() + require 'nvim-treesitter.configs'.setup { + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + highlight = { + enable = true, + }, + } + end, + }, + { + "williamboman/mason-lspconfig.nvim", + dependencies = { + "williamboman/mason.nvim" + }, + config = function() + require("mason").setup() + require("mason-lspconfig").setup() + end + }, + { + "neovim/nvim-lspconfig", + config = function() + require("configs.lspconfig") + end + }, + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + require("catppuccin").setup({ + background = { -- :h background + light = "latte", + dark = "mocha", + }, + styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): + comments = {}, -- Change the style of comments + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = { "italic" }, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = { "italic" }, + types = { "bold" }, + operators = {}, + }, + color_overrides = { + mocha = { + base = "#000000", + mantle = "#000000", + crust = "#000000", + }, + }, + custom_highlights = {}, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + treesitter = true, + mini = true, + mason = true, + telescope = { + enabled = true, + style = "nvchad" + }, + dap = { + enabled = true, + enable_ui = true, -- enable nvim-dap-ui + }, + native_lsp = { + enabled = true, + virtual_text = { + errors = { "italic" }, + hints = { "italic" }, + warnings = { "italic" }, + information = { "italic" }, + }, + underlines = { + errors = { "underline" }, + hints = { "underline" }, + warnings = { "underline" }, + information = { "underline" }, + }, + inlay_hints = { + background = true, + }, + }, + }, + }) + end, + }, + -- { + -- "Shatur/neovim-ayu", + -- config = function() + -- require('ayu').setup({ + -- options = { + -- theme = 'ayu', + -- }, + -- }) + -- end, + -- }, + -- Install without configuration + { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + }, + { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + -- cmp sources plugins + { + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + }, + }, + opts = function() + return require "configs.cmp" + end, + config = function(_, opts) + require("cmp").setup(opts) + end, + }, + { + "zbirenbaum/copilot.lua", + cmd = { "Copilot", "StartCopilot" }, + opts = { + suggestion = { + auto_trigger = true, + } + }, + config = function() + require("copilot").setup() + vim.cmd("command! StartCopilot Copilot suggestion") + end, + }, + { + 'nvim-lualine/lualine.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + 'arkav/lualine-lsp-progress', + }, + config = function() + require('lualine').setup(require("configs.lualine")) + end + }, + { + 'akinsho/bufferline.nvim', + version = "*", + dependencies = { 'nvim-tree/nvim-web-devicons', 'catppuccin/nvim' }, + config = function() + require("bufferline").setup { + highlights = require("catppuccin.groups.integrations.bufferline").get() + } + end + }, + { + 'numToStr/Comment.nvim', + lazy = false, + config = function() + require("Comment").setup() + end, + + }, + { + 'Wansmer/treesj', + keys = { 'm', 'j', 's' }, + dependencies = { 'nvim-treesitter/nvim-treesitter' }, + config = function() + require('treesj').setup({ + use_default_keymaps = false, + }) + end, + }, + { + "rmagatti/auto-session", + config = function() + require("auto-session").setup() + end, + }, + { + "ethanholz/nvim-lastplace", + config = function() + require("nvim-lastplace").setup() + end, + }, + { + 'nvim-telescope/telescope.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + }, + { + 'echasnovski/mini.files', + version = false, + config = function() + require('mini.files').setup() + end, + }, + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + }, + }, + { + "lewis6991/gitsigns.nvim", + config = function() require('gitsigns').setup() end, + }, +} + +return plugins