From 58e5dae036602c47521ca311b613d7c400005416 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 30 Dec 2022 17:30:52 +0100 Subject: [PATCH] feat: initial commit --- .neoconf.json | 15 ++++++ init.lua | 4 ++ lazy-lock.json | 34 ++++++++++++ lua/user/autocommands.lua | 40 ++++++++++++++ lua/user/lazy.lua | 30 +++++++++++ lua/user/mappings.lua | 66 +++++++++++++++++++++++ lua/user/options.lua | 51 ++++++++++++++++++ lua/user/plugins/api.lua | 6 +++ lua/user/plugins/coding.lua | 90 +++++++++++++++++++++++++++++++ lua/user/plugins/colorscheme.lua | 17 ++++++ lua/user/plugins/editor.lua | 35 ++++++++++++ lua/user/plugins/lsp/format.lua | 49 +++++++++++++++++ lua/user/plugins/lsp/init.lua | 49 +++++++++++++++++ lua/user/plugins/lsp/mappings.lua | 70 ++++++++++++++++++++++++ lua/user/plugins/lsp/servers.lua | 25 +++++++++ lua/user/plugins/treesitter.lua | 16 ++++++ lua/user/plugins/ui.lua | 83 ++++++++++++++++++++++++++++ stylua.toml | 3 ++ 18 files changed, 683 insertions(+) create mode 100644 .neoconf.json create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/user/autocommands.lua create mode 100644 lua/user/lazy.lua create mode 100644 lua/user/mappings.lua create mode 100644 lua/user/options.lua create mode 100644 lua/user/plugins/api.lua create mode 100644 lua/user/plugins/coding.lua create mode 100644 lua/user/plugins/colorscheme.lua create mode 100644 lua/user/plugins/editor.lua create mode 100644 lua/user/plugins/lsp/format.lua create mode 100644 lua/user/plugins/lsp/init.lua create mode 100644 lua/user/plugins/lsp/mappings.lua create mode 100644 lua/user/plugins/lsp/servers.lua create mode 100644 lua/user/plugins/treesitter.lua create mode 100644 lua/user/plugins/ui.lua create mode 100644 stylua.toml diff --git a/.neoconf.json b/.neoconf.json new file mode 100644 index 00000000..aa1b504a --- /dev/null +++ b/.neoconf.json @@ -0,0 +1,15 @@ +{ + "neodev": { + "library": { + "enabled": true, + "plugins": true + } + }, + "neoconf": { + "plugins": { + "sumneko_lua": { + "enabled": true + } + } + } +} diff --git a/init.lua b/init.lua new file mode 100644 index 00000000..35e4b0bc --- /dev/null +++ b/init.lua @@ -0,0 +1,4 @@ +require("user.options") +require("user.lazy") +require("user.autocommands") +require("user.mappings") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..47ed428f --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,34 @@ +{ + "LuaSnip": { "branch": "master", "commit": "563827f00bb4fe43269e3be653deabc0005f1302" }, + "alpha-nvim": { "branch": "main", "commit": "21a0f2520ad3a7c32c0822f943368dc063a569fb" }, + "catppuccin": { "branch": "main", "commit": "26e498db297607fe17a6206c5a28f0f4cb532954" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "dressing.nvim": { "branch": "master", "commit": "4436d6f41e2f6b8ada57588acd1a9f8b3d21453c" }, + "friendly-snippets": { "branch": "main", "commit": "1a6a02350568d6830bcfa167c72f9b6e75e454ae" }, + "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" }, + "indent-blankline.nvim": { "branch": "master", "commit": "db7cbcb40cc00fc5d6074d7569fb37197705e7f6" }, + "lualine.nvim": { "branch": "master", "commit": "32a7382a75a52e8ad05f4cec7eeb8bbfbe80d461" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "698713735933a5891080fc3d87a687f90b9d2aee" }, + "mason.nvim": { "branch": "main", "commit": "1592493e3406c271e9128b4d424731e25f1ff2a1" }, + "mini.comment": { "branch": "main", "commit": "e5294cc3e75bafb2369f235d31a98b01a9cc67ad" }, + "mini.pairs": { "branch": "main", "commit": "fec9aba50912d8c3d92d07d6a77952de84f8d7ad" }, + "neo-tree.nvim": { "branch": "v2.x", "commit": "3b41f0d17139bb156f1acd907608f63e0e307caf" }, + "neoconf.nvim": { "branch": "main", "commit": "c50f45c0338073a5c2e8ddacc325e8231e22cefd" }, + "neodev.nvim": { "branch": "main", "commit": "8e06acf88e0621badd9499cfcafbce5ca97dfe8e" }, + "nui.nvim": { "branch": "main", "commit": "4939282919885e1c83aff68ecb35b3cadf6015a9" }, + "null-ls.nvim": { "branch": "main", "commit": "647a1eeeefc43ce15d941972642210637c370471" }, + "nvim-bufferline.lua": { "branch": "main", "commit": "028a87933d99f8bb88f2f70a4def3ff9574f3594" }, + "nvim-cmp": { "branch": "main", "commit": "983453e32cb35533a119725883c04436d16c0120" }, + "nvim-lspconfig": { "branch": "master", "commit": "22c87d6f48c4fb1daf33476450d0b14a64230809" }, + "nvim-notify": { "branch": "master", "commit": "b005821516f1f37801a73067afd1cef2dbc4dfe8" }, + "nvim-treesitter": { "branch": "master", "commit": "69388e84c34d40c3d5c7d2f310db13276f2179e1" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "32d9627123321db65a4f158b72b757bcaef1a3f4" }, + "nvim-web-devicons": { "branch": "master", "commit": "05e1072f63f6c194ac6e867b567e6b437d3d4622" }, + "plenary.nvim": { "branch": "master", "commit": "4b7e52044bbb84242158d977a50c4cbcd85070c7" }, + "telescope.nvim": { "branch": "master", "commit": "b79cd6c88b3d96b0f49cb7d240807cd59b610cd8" }, + "tokyonight.nvim": { "branch": "main", "commit": "8a619f0cf3ed9051081d9fc0cd4f852a7355f546" }, + "which-key.nvim": { "branch": "main", "commit": "8682d3003595017cd8ffb4c860a07576647cc6f8" } +} \ No newline at end of file diff --git a/lua/user/autocommands.lua b/lua/user/autocommands.lua new file mode 100644 index 00000000..7ca38210 --- /dev/null +++ b/lua/user/autocommands.lua @@ -0,0 +1,40 @@ +-- Check if we need to reload the file when it changed +vim.api.nvim_create_autocmd("FocusGained", { command = "checktime" }) + +-- Highlight on yank +vim.api.nvim_create_autocmd("TextYankPost", { callback = vim.highlight.on_yank }) + +-- go to last loc when opening a buffer +vim.api.nvim_create_autocmd("BufReadPre", { + pattern = "*", + callback = function() + vim.api.nvim_create_autocmd("FileType", { + pattern = "", + once = true, + callback = function() + vim.cmd( + [[if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"' | endif]] + ) + end, + }) + end, +}) + +-- close some filetypes with +vim.api.nvim_create_autocmd({ "FileType" }, { + pattern = { + "qf", + "help", + "man", + "notify", + "lspinfo", + "spectre_panel", + "startuptime", + "tsplayground", + "PlenaryTestPopup", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) + end, +}) diff --git a/lua/user/lazy.lua b/lua/user/lazy.lua new file mode 100644 index 00000000..d4230c11 --- /dev/null +++ b/lua/user/lazy.lua @@ -0,0 +1,30 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath }) + vim.fn.system({ "git", "-C", lazypath, "checkout", "tags/stable" }) -- last stable release + end +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("user.plugins", { + defaults = { lazy = true, version = "*" }, + install = { colorscheme = { "tokyonight", "habamax" } }, + checker = { enabled = true }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + "nvim-treesitter-textobjects", + }, + }, + }, +}) +vim.keymap.set("n", "l", ":Lazy") diff --git a/lua/user/mappings.lua b/lua/user/mappings.lua new file mode 100644 index 00000000..8921648b --- /dev/null +++ b/lua/user/mappings.lua @@ -0,0 +1,66 @@ +-- Move to window using the movement keys +vim.keymap.set("n", "", "h") +vim.keymap.set("n", "", "j") +vim.keymap.set("n", "", "k") +vim.keymap.set("n", "", "l") + +-- Resize window using arrow keys +vim.keymap.set("n", "", "resize +2") +vim.keymap.set("n", "", "resize -2") +vim.keymap.set("n", "", "vertical resize -2") +vim.keymap.set("n", "", "vertical resize +2") + +-- Move Lines +vim.keymap.set("n", "", ":m .+1==") +vim.keymap.set("v", "", ":m '>+1gv=gv") +vim.keymap.set("i", "", ":m .+1==gi") +vim.keymap.set("n", "", ":m .-2==") +vim.keymap.set("v", "", ":m '<-2gv=gv") +vim.keymap.set("i", "", ":m .-2==gi") + +-- Switch buffers with +vim.keymap.set("n", "", "bprevious") +vim.keymap.set("n", "", "bnext") + +-- Easier pasting +vim.keymap.set("n", "[p", ":pu!") +vim.keymap.set("n", "]p", ":pu") + +-- Clear search with +vim.keymap.set({ "i", "n" }, "", "noh") +vim.keymap.set("n", "gw", "*N") +vim.keymap.set("x", "gw", "*N") + +-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n +vim.keymap.set("n", "n", "'Nn'[v:searchforward]", { expr = true }) +vim.keymap.set("x", "n", "'Nn'[v:searchforward]", { expr = true }) +vim.keymap.set("o", "n", "'Nn'[v:searchforward]", { expr = true }) +vim.keymap.set("n", "N", "'nN'[v:searchforward]", { expr = true }) +vim.keymap.set("x", "N", "'nN'[v:searchforward]", { expr = true }) +vim.keymap.set("o", "N", "'nN'[v:searchforward]", { expr = true }) + +-- Add undo break-points +vim.keymap.set("i", ",", ",u") +vim.keymap.set("i", ".", ".u") +vim.keymap.set("i", ";", ";u") + +-- save in insert mode +vim.keymap.set("i", "", ":w") +vim.keymap.set("n", "", ":w") + +-- better indenting +vim.keymap.set("v", "<", "", ">gv") + +-- makes * and # work on visual mode too. +vim.cmd([[ + function! g:VSetSearch(cmdtype) + let temp = @s + norm! gv"sy + let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g') + let @s = temp + endfunction + + xnoremap * :call g:VSetSearch('/')/=@/ + xnoremap # :call g:VSetSearch('?')?=@/ +]]) diff --git a/lua/user/options.lua b/lua/user/options.lua new file mode 100644 index 00000000..325bbe38 --- /dev/null +++ b/lua/user/options.lua @@ -0,0 +1,51 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +vim.opt.autowrite = true -- enable auto write +vim.opt.clipboard = "unnamedplus" -- sync with system clipboard +vim.opt.cmdheight = 1 +vim.opt.completeopt = "menu,menuone,noselect" +vim.opt.conceallevel = 3 -- Hide * markup for bold and italic +vim.opt.confirm = true -- confirm to save changes before exiting modified buffer +vim.opt.cursorline = true -- Enable highlighting of the current line +vim.opt.expandtab = true -- Use spaces instead of tabs +vim.opt.formatoptions = "jcroqlnt" -- tcqj +vim.opt.grepformat = "%f:%l:%c:%m" +vim.opt.grepprg = "rg --vimgrep" +vim.opt.guifont = "FiraCode Nerd Font:h11" +vim.opt.hidden = true -- Enable modified buffers in background +vim.opt.ignorecase = true -- Ignore case +vim.opt.inccommand = "nosplit" -- preview incremental substitute +vim.opt.joinspaces = false -- No double spaces with join after a dot +vim.opt.laststatus = 0 +vim.opt.list = true -- Show some invisible characters (tabs... +vim.opt.mouse = "a" -- enable mouse mode +vim.opt.number = true -- Print line number +vim.opt.pumblend = 10 -- Popup blend +vim.opt.pumheight = 10 -- Maximum number of entries in a popup +vim.opt.relativenumber = true -- Relative line numbers +vim.opt.scrolloff = 4 -- Lines of context +vim.opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } +vim.opt.shiftround = true -- Round indent +vim.opt.shiftwidth = 2 -- Size of an indent +vim.opt.shortmess = "filnxtToOFWIcC" +vim.opt.showmode = false -- dont show mode since we have a statusline +vim.opt.sidescrolloff = 8 -- Columns of context +vim.opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time +vim.opt.smartcase = true -- Don't ignore case with capitals +vim.opt.smartindent = true -- Insert indents automatically +vim.opt.spelllang = { "en" } +vim.opt.splitbelow = true -- Put new windows below current +vim.opt.splitkeep = "screen" +vim.opt.splitright = true -- Put new windows right of current +vim.opt.tabstop = 2 -- Number of spaces tabs count for +vim.opt.termguicolors = true -- True color support +vim.opt.timeoutlen = 300 +vim.opt.undofile = true +vim.opt.undolevels = 10000 +vim.opt.updatetime = 200 -- save swap file and trigger CursorHold +vim.opt.wildmode = "longest:full,full" -- Command-line completion mode +vim.opt.wrap = false -- Disable line wrap + +-- fix markdown indentation settings +vim.g.markdown_recommended_style = 0 diff --git a/lua/user/plugins/api.lua b/lua/user/plugins/api.lua new file mode 100644 index 00000000..f631192e --- /dev/null +++ b/lua/user/plugins/api.lua @@ -0,0 +1,6 @@ +-- plugins that provide apis for other plugins +return { + "nvim-tree/nvim-web-devicons", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", +} diff --git a/lua/user/plugins/coding.lua b/lua/user/plugins/coding.lua new file mode 100644 index 00000000..def53ad4 --- /dev/null +++ b/lua/user/plugins/coding.lua @@ -0,0 +1,90 @@ +return { + + -- git signs + { + "lewis6991/gitsigns.nvim", + event = "BufReadPre", + config = { + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + untracked = { hl = "GitSignsAdd", text = "▍", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + }, + }, + }, + + -- snippets + { + "L3MON4D3/LuaSnip", + dependencies = { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + }, + + -- auto completion + { + + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + + config = function() + local cmp = require("cmp") + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + 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 }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + end, + }, + + -- auto pairs + { + "echasnovski/mini.pairs", + config = function() + require("mini.pairs").setup({}) + end, + }, + + -- comments + { "JoosepAlviste/nvim-ts-context-commentstring" }, + { + "echasnovski/mini.comment", + event = "VeryLazy", + config = function() + require("mini.comment").setup({ + hooks = { + pre = function() + require("ts_context_commentstring.internal").update_commentstring({}) + end, + }, + }) + end, + }, +} diff --git a/lua/user/plugins/colorscheme.lua b/lua/user/plugins/colorscheme.lua new file mode 100644 index 00000000..1dc86488 --- /dev/null +++ b/lua/user/plugins/colorscheme.lua @@ -0,0 +1,17 @@ +return { + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + config = function() + require("tokyonight").setup({ style = "moon" }) + vim.cmd.colorscheme("tokyonight") + end, + }, + + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + }, +} diff --git a/lua/user/plugins/editor.lua b/lua/user/plugins/editor.lua new file mode 100644 index 00000000..c41c5a54 --- /dev/null +++ b/lua/user/plugins/editor.lua @@ -0,0 +1,35 @@ +vim.g.neo_tree_remove_legacy_commands = 1 + +return { + + -- file explorer + { + "nvim-neo-tree/neo-tree.nvim", + cmd = "Neotree", + keys = { { "ft", "Neotree toggle", desc = "NeoTree" } }, + config = { + filesystem = { + follow_current_file = true, + hijack_netrw_behavior = "open_current", + }, + }, + }, + + -- fuzzy finder + { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + keys = { { "", "Telescope find_files", desc = "Find Files" } }, + config = true, + }, + + -- which-key + { + "folke/which-key.nvim", + event = "VeryLazy", + config = { + plugins = { spelling = true }, + key_labels = { [""] = "SPC" }, + }, + }, +} diff --git a/lua/user/plugins/lsp/format.lua b/lua/user/plugins/lsp/format.lua new file mode 100644 index 00000000..d257e58f --- /dev/null +++ b/lua/user/plugins/lsp/format.lua @@ -0,0 +1,49 @@ +local M = {} + +M.autoformat = true + +function M.toggle() + M.autoformat = not M.autoformat + if M.autoformat then + vim.notify("enabled format on save") + else + vim.notify("disabled format on save") + end +end + +function M.format() + if M.autoformat then + vim.lsp.buf.format() + end +end + +function M.nls_formatter(ft) + local sources = require("null-ls.sources") + local available = sources.get_available(ft, "NULL_LS_FORMATTING") + return #available > 0 +end + +function M.on_attach(client, buf) + local ft = vim.api.nvim_buf_get_option(buf, "filetype") + + local enable = false + if M.nls_formatter(ft) then + enable = client.name == "null-ls" + else + enable = not (client.name == "null-ls") + end + + client.server_capabilities.documentFormattingProvider = enable + -- format on save + if client.server_capabilities.documentFormattingProvider then + vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("LspFormat", {}), + buffer = 0, + callback = function() + M.format() + end, + }) + end +end + +return M diff --git a/lua/user/plugins/lsp/init.lua b/lua/user/plugins/lsp/init.lua new file mode 100644 index 00000000..00c28f04 --- /dev/null +++ b/lua/user/plugins/lsp/init.lua @@ -0,0 +1,49 @@ +local servers = require("user.plugins.lsp.servers") +local function on_attach(client, bufnr) + require("user.plugins.lsp.format").on_attach(client, bufnr) + require("user.plugins.lsp.mappings").on_attach(client, bufnr) +end + +return { + -- lspconfig + { + "neovim/nvim-lspconfig", + event = "BufReadPre", + dependencies = { + { "folke/neoconf.nvim", cmd = "Neoconf", config = true }, + { "folke/neodev.nvim", config = true }, + { "williamboman/mason.nvim", config = true }, + { "williamboman/mason-lspconfig.nvim", config = { ensure_installed = vim.tbl_keys(servers) } }, + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + ---@type _.lspconfig.options + local defaults = { + on_attach = on_attach, + capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + } + + for server, opts in pairs(servers) do + opts = vim.tbl_deep_extend("force", {}, defaults, opts or {}) + require("lspconfig")[server].setup(opts) + end + end, + }, + + -- formatters + { + "jose-elias-alvarez/null-ls.nvim", + event = "BufReadPre", + config = function() + local nls = require("null-ls") + nls.setup({ + on_attach = on_attach, + sources = { + -- nls.builtins.formatting.prettierd, + nls.builtins.formatting.stylua, + nls.builtins.diagnostics.flake8, + }, + }) + end, + }, +} diff --git a/lua/user/plugins/lsp/mappings.lua b/lua/user/plugins/lsp/mappings.lua new file mode 100644 index 00000000..455c9e15 --- /dev/null +++ b/lua/user/plugins/lsp/mappings.lua @@ -0,0 +1,70 @@ +local M = {} + +function M.on_attach(client, buffer) + local cap = client.server_capabilities + + require("which-key").register({ + buffer = buffer, + [""] = { + c = { + name = "+code", + { + cond = client.name == "tsserver", + o = { ":TypescriptOrganizeImports", "Organize Imports" }, + R = { ":TypescriptRenameFile", "Rename File" }, + }, + r = { "lua vim.lsp.buf.rename()", "Rename", cond = cap.renameProvider }, + a = { + { vim.lsp.buf.code_action, "Code Action" }, + { "lua vim.lsp.buf.code_action()", "Code Action", mode = "v" }, + }, + f = { + { + require("user.plugins.lsp.format").format, + "Format Document", + cond = cap.documentFormatting, + }, + { + require("user.plugins.lsp.format").format, + "Format Range", + cond = cap.documentRangeFormatting, + mode = "v", + }, + }, + d = { vim.diagnostic.open_float, "Line Diagnostics" }, + l = { + name = "+lsp", + i = { "LspInfo", "Lsp Info" }, + }, + }, + x = { + d = { "Telescope diagnostics", "Search Diagnostics" }, + }, + }, + g = { + name = "+goto", + d = { "Telescope lsp_definitions", "Goto Definition" }, + r = { "Telescope lsp_references", "References" }, + R = { "Trouble lsp_references", "Trouble References" }, + D = { "Telescope lsp_declarations", "Goto Declaration" }, + I = { "Telescope lsp_implementations", "Goto Implementation" }, + t = { "Telescope lsp_type_definitions", "Goto Type Definition" }, + }, + [""] = { "lua vim.lsp.buf.signature_help()", "Signature Help", mode = { "n", "i" } }, + ["K"] = { "lua vim.lsp.buf.hover()", "Hover" }, + ["[d"] = { "lua vim.diagnostic.goto_prev()", "Next Diagnostic" }, + ["]d"] = { "lua vim.diagnostic.goto_next()", "Prev Diagnostic" }, + ["[e"] = { "lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})", "Next Error" }, + ["]e"] = { "lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})", "Prev Error" }, + ["[w"] = { + "lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.WARNING})", + "Next Warning", + }, + ["]w"] = { + "lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.WARNING})", + "Prev Warning", + }, + }) +end + +return M diff --git a/lua/user/plugins/lsp/servers.lua b/lua/user/plugins/lsp/servers.lua new file mode 100644 index 00000000..726a6df9 --- /dev/null +++ b/lua/user/plugins/lsp/servers.lua @@ -0,0 +1,25 @@ +---@type lspconfig.options +local servers = { + bashls = {}, + clangd = {}, + cssls = {}, + tsserver = {}, + html = {}, + jsonls = {}, + pyright = {}, + yamlls = {}, + sumneko_lua = { + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + completion = { + callSnippet = "Replace", + }, + }, + }, + }, +} + +return servers diff --git a/lua/user/plugins/treesitter.lua b/lua/user/plugins/treesitter.lua new file mode 100644 index 00000000..3ae91aa1 --- /dev/null +++ b/lua/user/plugins/treesitter.lua @@ -0,0 +1,16 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "BufReadPost", + config = function() + require("nvim-treesitter.configs").setup({ + sync_install = false, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + context_commentstring = { enable = true, enable_autocmd = false }, + }) + end, + }, +} diff --git a/lua/user/plugins/ui.lua b/lua/user/plugins/ui.lua new file mode 100644 index 00000000..1061eebd --- /dev/null +++ b/lua/user/plugins/ui.lua @@ -0,0 +1,83 @@ +return { + -- better vim.notify + { + "rcarriga/nvim-notify", + event = "VeryLazy", + config = function() + vim.notify = require("notify") + end, + }, + + -- better vim.ui + { + "stevearc/dressing.nvim", + event = "VeryLazy", + config = true, + }, + + -- bufferline + { + "akinsho/nvim-bufferline.lua", + event = "BufAdd", + config = true, + }, + + -- statusline + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + config = true, + }, + + -- indent guides for Neovim + { + "lukas-reineke/indent-blankline.nvim", + event = "BufReadPre", + config = { + char = "▏", + }, + }, + + -- dashboard + { + "goolord/alpha-nvim", + lazy = false, + config = function() + local dashboard = require("alpha.themes.dashboard") + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ +]] + + dashboard.section.header.val = vim.split(logo, "\n") + dashboard.section.buttons.val = { + dashboard.button("f", " " .. " Find file", ":Telescope find_files "), + dashboard.button("n", " " .. " New file", ":ene startinsert "), + dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), + dashboard.button("g", " " .. " Find text", ":Telescope live_grep "), + dashboard.button("c", " " .. " Config", ":e $MYVIMRC "), + dashboard.button("q", " " .. " Quit", ":qa"), + } + dashboard.section.footer.opts.hl = "Type" + dashboard.section.header.opts.hl = "Include" + dashboard.section.buttons.opts.hl = "Keyword" + dashboard.opts.opts.noautocmd = true + + require("alpha").setup(dashboard.opts) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + callback = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + dashboard.section.footer.val = "🎉 Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" + pcall(vim.cmd.AlphaRedraw) + end, + }) + end, + }, +} diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 00000000..5d6c50dc --- /dev/null +++ b/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 120 \ No newline at end of file