initial commit

This commit is contained in:
ant 2023-08-11 21:22:09 +02:00
commit 970a7c22e1
8 changed files with 477 additions and 0 deletions

1
.gitignore vendored Normal file
View file

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

54
init.lua Normal file
View file

@ -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")

13
lua/bootstrap.lua Normal file
View file

@ -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)

33
lua/configs/cmp.lua Normal file
View file

@ -0,0 +1,33 @@
local cmp = require "cmp"
local options = {
completion = {
completeopt = 'menu,menuone,noinsert,noselect'
},
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.Replace,
select = false,
},
["<Tab>"] = function(callback)
callback()
end,
["<S-Tab>"] = function(callback)
callback()
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "path" },
},
}
return options

34
lua/configs/lspconfig.lua Normal file
View file

@ -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
}

41
lua/configs/lualine.lua Normal file
View file

@ -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

73
lua/mappings.lua Normal file
View file

@ -0,0 +1,73 @@
vim.keymap.set("i", "<C-h>", "<Left>", { desc = "Move left" })
vim.keymap.set("i", "<C-l>", "<Right>", { desc = "Move right" })
vim.keymap.set("i", "<C-j>", "<Down>", { desc = "Move down" })
vim.keymap.set("i", "<C-k>", "<Up>", { desc = "Move up" })
vim.keymap.set("n", "<Esc>", ":noh<CR>", { desc = "Clear highlights" })
vim.keymap.set("n", "<leader>b", "<cmd> enew <CR>", { desc = "New buffer" })
vim.keymap.set("n", "<leader>x", "<cmd> bdelete <CR>", { desc = "Delete buffer" })
vim.keymap.set("n", "<Tab>", "<cmd> bn <CR>", { desc = "Next buffer" })
vim.keymap.set("n", "<S-Tab>", "<cmd> bp <CR>", { desc = "Previous buffer" })
vim.keymap.set("n", "ZZ", "<cmd> q! <CR>", { desc = "Quit without saving" })
vim.keymap.set('n', 'H', require('treesj').toggle)
vim.keymap.set(
'n',
'<leader>ff',
"<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>"
)
vim.keymap.set('n', '<leader>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 <c-x><c-o>
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', '<leader>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', '<leader>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', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>ra', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<leader>fm', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})
-- Descriptions for lspconfig mappings
local wk = require("which-key")
wk.register({
["<leader>e"] = { vim.diagnostic.open_float, "Show diagnostics" },
["[["] = { vim.diagnostic.goto_prev, "Previous diagnostic" },
["]]"] = { vim.diagnostic.goto_next, "Next diagnostic" },
["<leader>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" },
["<C-k>"] = { vim.lsp.buf.signature_help, "Signature help" },
["<leader>D"] = { vim.lsp.buf.type_definition, "Goto type definition" },
["<leader>ra"] = { vim.lsp.buf.rename, "Rename" },
["<leader>ca"] = { vim.lsp.buf.code_action, "Code action" },
["gr"] = { vim.lsp.buf.references, "Goto references" },
["<leader>fm"] = { function()
vim.lsp.buf.format { async = true }
end, "Format" },
})

228
lua/plugins.lua Normal file
View file

@ -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 = { '<space>m', '<space>j', '<space>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