diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-11-04 07:35:34 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2024-11-04 07:35:34 +0100 |
commit | 379cd763460659bfdbd49386108a9a5ab68663c2 (patch) | |
tree | 8778abcf5ee27a6e781e5179fd4d6ef0b6ee9523 /lua/config | |
parent | 68b90b79f06a0fa09866f35e84e4c72405ac547d (diff) |
checkpoint
Diffstat (limited to 'lua/config')
-rw-r--r-- | lua/config/lazy.lua | 90 | ||||
-rw-r--r-- | lua/config/lsp.lua | 64 | ||||
-rw-r--r-- | lua/config/map.lua | 12 |
3 files changed, 121 insertions, 45 deletions
diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 4c053d0..a61e3b4 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -23,51 +23,51 @@ require("lazy").setup({ "jghauser/follow-md-links.nvim", "m4xshen/autoclose.nvim", "stevearc/conform.nvim", - "mfussenegger/nvim-lint", - "neovim/nvim-lspconfig", - { - "norcalli/nvim-colorizer.lua", - config = function() - -- require("colorizer").setup() - end, - }, - - { - "williamboman/mason.nvim", - dependencies = { - "williamboman/mason-lspconfig.nvim", - -- for formatters and linters - "WhoIsSethDaniel/mason-tool-installer.nvim", - }, - config = function() - require("mason").setup({ - ui = { - border = "rounded", - }, - }) - end, - }, - { - "ray-x/lsp_signature.nvim", - event = "LspAttach", - }, - { - --snippets - "L3MON4D3/LuaSnip", - version = "v2.*", - build = "make install_jsregexp", - }, - { - "hrsh7th/nvim-cmp", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "hrsh7th/cmp-buffer", - "saadparwaiz1/cmp_luasnip", - "onsails/lspkind.nvim", - }, - event = { "InsertEnter", "CmdlineEnter" }, - }, + -- "mfussenegger/nvim-lint", + -- "neovim/nvim-lspconfig", + -- { + -- "norcalli/nvim-colorizer.lua", + -- config = function() + -- -- require("colorizer").setup() + -- end, + -- }, + -- + -- { + -- "williamboman/mason.nvim", + -- dependencies = { + -- "williamboman/mason-lspconfig.nvim", + -- -- for formatters and linters + -- "WhoIsSethDaniel/mason-tool-installer.nvim", + -- }, + -- config = function() + -- require("mason").setup({ + -- ui = { + -- border = "rounded", + -- }, + -- }) + -- end, + -- }, + -- { + -- "ray-x/lsp_signature.nvim", + -- event = "LspAttach", + -- }, + -- { + -- --snippets + -- "L3MON4D3/LuaSnip", + -- version = "v2.*", + -- build = "make install_jsregexp", + -- }, + -- { + -- "hrsh7th/nvim-cmp", + -- dependencies = { + -- "hrsh7th/cmp-nvim-lsp", + -- "hrsh7th/cmp-path", + -- "hrsh7th/cmp-buffer", + -- "saadparwaiz1/cmp_luasnip", + -- "onsails/lspkind.nvim", + -- }, + -- event = { "InsertEnter", "CmdlineEnter" }, + -- }, { "folke/which-key.nvim", diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index b50b4b6..977c629 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -113,3 +113,67 @@ autocmd("LspAttach", { end end, }) + +local ls = require("luasnip") + +local map = vim.keymap.set +local parse_snippet = ls.parser.parse_snippet + +map({ "i", "s" }, "<C-h>", function() + if ls.expand_or_locally_jumpable() then + ls.expand_or_jump() + end +end, { silent = true }) +map({ "i", "s" }, "<C-l>", function() + if ls.locally_jumpable(-1) then + ls.jump(-1) + end +end, { silent = true }) +map({ "i", "s" }, "<C-c>", function() + if ls.choice_active() then + ls.change_choice(1) + end +end, { silent = true }) + +-- temporary keybind to play around +map("n", " s", "<cmd>source ~/.config/nvim/after/plugin/luasnip.lua<cr>") + +ls.config.set_config({ + history = true, + -- Will update multiple nodes at the same time when in insert mode + update_events = { "TextChanged", "TextChangedI" }, +}) + +ls.add_snippets("go", { + parse_snippet("main", "package main\n\nfunc main() {\n\t$0\n}"), + parse_snippet("e", "if err != nil {\n\tpanic(err)$1\n}\n$0"), + parse_snippet("ee", "if err != nil {\n\tfmt.Fprintln(os.Stderr, err)$1\n\tos.Exit(${2:1})\n}\n$0"), + parse_snippet("eif", "if err := $1; err != nil {\n\tfmt.Println(err)$2\n}\n$0"), + parse_snippet("pf", "fmt.Printf($0)"), + parse_snippet("pl", "fmt.Println($0)"), +}) +ls.add_snippets("sh", { + parse_snippet("!", "#!/bin/sh\n$0"), + parse_snippet("if", "if ${1:condition}; then\n\t$0\nfi"), + parse_snippet("while", "while ${1:condition}; do\n\t$0\ndone"), + parse_snippet("for", "for ${1:v} in ${2:list}; do\n\t$0\ndone"), + parse_snippet("case", "case ${1:\\$var} in\n\t$0\nesac"), +}) +ls.add_snippets("c", { + parse_snippet("main", "int main(void) {\n\t$0\n\treturn 0;\n}"), + parse_snippet( + "uints", + [[#include <stdint.h> +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +]] + ), +}) +ls.add_snippets("typescript", { parse_snippet("cl", "console.log($0);") }) +ls.add_snippets("html", { parse_snippet("t", [[<$1>$0</$1>]]) }) diff --git a/lua/config/map.lua b/lua/config/map.lua index c676ba5..ace8134 100644 --- a/lua/config/map.lua +++ b/lua/config/map.lua @@ -96,3 +96,15 @@ end, { desc = "Toggle diagnostics" }) -- editing map("n", " sf", ":%s/\\<<C-R><C-W>\\>//gc<Left><Left><Left>", { desc = "Replace word under cursor in file" }) map("n", " sl", ":s/\\<<C-R><C-W>\\>//g<Left><Left>", { desc = "Replace word under cursor on current line" }) + +map("n", "]q", "<cmd>cn<cr>", { desc = "Next item in quickfix", silent = true }) +map("n", "[q", "<cmd>cp<cr>", { desc = "Next item in quickfix", silent = true }) + +vim.api.nvim_create_user_command("Scratch", function() + vim.cmd([[ + e scratch + setlocal buftype=nofile + setlocal bufhidden=hide + setlocal noswapfile + ]]) +end, {}) |