summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2023-04-02 17:44:43 +0200
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2023-04-02 17:44:43 +0200
commit65f0046083b6239bdd76a81af63e3cad4516c75a (patch)
tree46677f49f4d34e40f6a0c8ae87732823c836f6c6
Initial commit
-rw-r--r--.gitattributes2
-rw-r--r--init.lua9
-rw-r--r--lazy-lock.json17
-rw-r--r--lua/config.lua27
-rw-r--r--lua/lsp.lua23
-rw-r--r--lua/my_telescope.lua25
-rw-r--r--lua/packages.lua50
-rw-r--r--lua/remap.lua4
-rw-r--r--lua/theme.lua21
-rw-r--r--lua/treesitter.lua48
10 files changed, 226 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfe0770
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..2dba404
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,9 @@
+vim.g.mapleader = " "
+
+require("packages")
+require("treesitter")
+require("lsp")
+require("my_telescope")
+require("theme")
+require("config")
+require("remap")
diff --git a/lazy-lock.json b/lazy-lock.json
new file mode 100644
index 0000000..3845464
--- /dev/null
+++ b/lazy-lock.json
@@ -0,0 +1,17 @@
+{
+ "LuaSnip": { "branch": "master", "commit": "bc8ec05022743d3f08bda7a76c6bb5e9a9024581" },
+ "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
+ "lazy.nvim": { "branch": "main", "commit": "57cce98dfdb2f2dd05a0567d89811e6d0505e13b" },
+ "lsp-zero.nvim": { "branch": "v2.x", "commit": "6d464367abbe47df6303cb98fec972c12cb88daf" },
+ "lualine.nvim": { "branch": "master", "commit": "9170434aa100f3967b43d5d34bb9adc56fae1986" },
+ "mason-lspconfig.nvim": { "branch": "main", "commit": "b64fdede85fd5e0b720ce722919e0a9b95ed6547" },
+ "mason.nvim": { "branch": "main", "commit": "aa8b3055868a1a2740ee50317cf4bbdfea6d49cb" },
+ "nvim-cmp": { "branch": "main", "commit": "777450fd0ae289463a14481673e26246b5e38bf2" },
+ "nvim-lspconfig": { "branch": "master", "commit": "0bc0c38e1b11dfb6b5f1794d53869f89ccf9e78f" },
+ "nvim-treesitter": { "branch": "master", "commit": "cbfa7cae1b38e1b843b2275d633ddbb05a105906" },
+ "nvim-treesitter-textobjects": { "branch": "master", "commit": "b55fe6175f0001347a433c9df358c8cbf8a4e90f" },
+ "nvim-web-devicons": { "branch": "master", "commit": "d92b3f4275f4774c0cb23b8b094a41d1dbb3e78c" },
+ "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" },
+ "telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" },
+ "vscode.nvim": { "branch": "main", "commit": "9cf814fbc1e7ec05fe05e5381beee2ceec5b099c" }
+} \ No newline at end of file
diff --git a/lua/config.lua b/lua/config.lua
new file mode 100644
index 0000000..b5b9d89
--- /dev/null
+++ b/lua/config.lua
@@ -0,0 +1,27 @@
+vim.o.shiftwidth = 4
+vim.o.tabstop = 4
+vim.o.softtabstop = 4
+vim.o.expandtab = true
+
+vim.o.hlsearch = false
+vim.o.number = true
+vim.o.mouse = "a"
+vim.o.ignorecase = true
+vim.o.smartcase = true
+vim.o.updatetime = 100
+vim.o.timeout = true
+vim.o.timeoutlen = 300
+vim.o.completeopt = "menuone,noselect"
+vim.o.termguicolors = true
+vim.o.swapfile = false
+vim.o.backup = false
+vim.o.incsearch = true
+vim.o.scrolloff = 5
+vim.o.colorcolumn = "80,120"
+
+vim.o.autoread = true
+vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "CursorHoldI", "FocusGained" }, {
+ command = "if mode() != 'c' | checktime | endif",
+ pattern = { "*" },
+})
+
diff --git a/lua/lsp.lua b/lua/lsp.lua
new file mode 100644
index 0000000..4e0cf17
--- /dev/null
+++ b/lua/lsp.lua
@@ -0,0 +1,23 @@
+local lsp = require("lsp-zero").preset({})
+
+lsp.on_attach(function(client, b)
+ local nmap = function(keys, func, desc)
+ vim.keymap.set("n", keys, func, { buffer = b, desc = desc })
+ end
+
+ nmap("<f2>", vim.lsp.buf.rename, "Rename symbol")
+ nmap("<leader>ca", vim.lsp.buf.code_action, "Code action")
+ nmap("<f12>", vim.lsp.buf.definition, "Go to definition")
+ nmap("<leader>fr", require("telescope.builtin").lsp_references, "Find references")
+ nmap("<c-o>", require("telescope.builtin").lsp_document_symbols, "Find document symbols")
+ nmap("<c-h>", vim.lsp.buf.hover, "Signature help")
+end)
+
+lsp.ensure_installed({
+ "clangd",
+})
+
+require("lspconfig").clangd.setup({})
+
+lsp.setup()
+
diff --git a/lua/my_telescope.lua b/lua/my_telescope.lua
new file mode 100644
index 0000000..5f87981
--- /dev/null
+++ b/lua/my_telescope.lua
@@ -0,0 +1,25 @@
+require("telescope").setup({
+ pickers = {
+ buffers = {
+ mappings = {
+ i = {
+ ["<c-d>"] = "delete_buffer",
+ },
+ },
+ },
+ lsp_document_symbols = {
+ layout_config = { width = 0.8 },
+ symbol_width = 70,
+ },
+ },
+})
+
+local telescope_builtin = require("telescope.builtin")
+vim.keymap.set("n", "<c-p>", telescope_builtin.find_files, { desc = "Find file" })
+vim.keymap.set("n", "<c-s-f>", telescope_builtin.live_grep, { desc = "Find with grep" })
+vim.keymap.set("n", "<leader><leader>", telescope_builtin.buffers, { desc = "Find buffer" })
+vim.keymap.set("n", "<c-f>", telescope_builtin.current_buffer_fuzzy_find, { desc = "Search in buffer" })
+vim.keymap.set("n", "<leader>fd", telescope_builtin.diagnostics, { desc = "Find diagnostics" })
+vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
+vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" })
+
diff --git a/lua/packages.lua b/lua/packages.lua
new file mode 100644
index 0000000..ab26af7
--- /dev/null
+++ b/lua/packages.lua
@@ -0,0 +1,50 @@
+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)
+
+require("lazy").setup({
+ {
+ "nvim-telescope/telescope.nvim", tag = "0.1.1",
+ dependencies = { "nvim-lua/plenary.nvim" },
+ },
+ {
+ "Mofiqul/vscode.nvim",
+ },
+ {
+ "nvim-lualine/lualine.nvim",
+ dependencies = { "nvim-tree/nvim-web-devicons" },
+ },
+ {
+ "nvim-treesitter/nvim-treesitter",
+ dependencies = {
+ "nvim-treesitter/nvim-treesitter-textobjects",
+ },
+ build = ":TSUpdate",
+ },
+ {
+ "VonHeikemen/lsp-zero.nvim",
+ branch = "v2.x",
+ dependencies = {
+ {"neovim/nvim-lspconfig"},
+ {
+ "williamboman/mason.nvim",
+ build = function()
+ pcall(vim.cmd, "MasonUpdate")
+ end,
+ },
+ { "williamboman/mason-lspconfig.nvim" },
+ { "hrsh7th/nvim-cmp" },
+ { "hrsh7th/cmp-nvim-lsp" },
+ { "L3MON4D3/LuaSnip" },
+ },
+ },
+})
diff --git a/lua/remap.lua b/lua/remap.lua
new file mode 100644
index 0000000..d9ecd61
--- /dev/null
+++ b/lua/remap.lua
@@ -0,0 +1,4 @@
+vim.keymap.set("x", "d", "\"_d")
+vim.keymap.set("n", "d", "\"_d")
+vim.keymap.set("x", "D", "\"_D")
+vim.keymap.set("n", "D", "\"_D")
diff --git a/lua/theme.lua b/lua/theme.lua
new file mode 100644
index 0000000..d8d2475
--- /dev/null
+++ b/lua/theme.lua
@@ -0,0 +1,21 @@
+vim.o.background = "dark"
+
+local c = require("vscode.colors").get_colors()
+require("vscode").setup({
+ style = "dark",
+ group_overrides = {
+ ["@punctuation.bracket"] = { fg = c.vscFront },
+ },
+})
+
+vim.cmd.colorscheme("vscode")
+
+require("lualine").setup({
+ options = {
+ theme = "vscode",
+ icons_enabled = false,
+ component_separators = "|",
+ section_separators = "",
+ },
+})
+
diff --git a/lua/treesitter.lua b/lua/treesitter.lua
new file mode 100644
index 0000000..8113094
--- /dev/null
+++ b/lua/treesitter.lua
@@ -0,0 +1,48 @@
+require("nvim-treesitter.configs").setup({
+ ensured_installed = { "c", "cpp", "lua", "vim", "vimdoc" },
+ auto_install = false,
+ highlight = {
+ enable = true,
+ },
+ incremental_selection = {
+ enable = true,
+ keymaps = {
+ init_selection = "<c-s>",
+ node_incremental = "<c-s>",
+ node_decremental = "<m-s>",
+ },
+ },
+ textobjects = {
+ select = {
+ enable = true,
+ loookahead = true,
+ keymaps = {
+ ["aa"] = "@parameter.outer",
+ ["ia"] = "@parameter.inner",
+ ["af"] = "@function.outer",
+ ["if"] = "@function.inner",
+ },
+ },
+ move = {
+ enable = true,
+ goto_next_start = {
+ [")a"] = "@parameter.inner",
+ },
+ goto_previous_start = {
+ ["(a"] = "@parameter.inner",
+ },
+ },
+ swap = {
+ enable = true,
+ swap_next = {
+ ["<leader>a"] = "@parameter.inner",
+ },
+ swap_previous = {
+ ["<leader>A"] = "@parameter.inner",
+ },
+ },
+ },
+ indent = { enable = true, disable = { "python" } },
+ additional_vim_regex_highlighting = false,
+})
+