summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-11-04 07:35:34 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-11-04 07:35:34 +0100
commit379cd763460659bfdbd49386108a9a5ab68663c2 (patch)
tree8778abcf5ee27a6e781e5179fd4d6ef0b6ee9523
parent68b90b79f06a0fa09866f35e84e4c72405ac547d (diff)
checkpoint
-rw-r--r--after/ftplugin/c.lua5
-rw-r--r--after/plugin/conform.lua76
-rw-r--r--after/plugin/luasnip.lua63
-rw-r--r--init.lua2
-rw-r--r--lua/config/lazy.lua90
-rw-r--r--lua/config/lsp.lua64
-rw-r--r--lua/config/map.lua12
7 files changed, 164 insertions, 148 deletions
diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua
index b5b06d0..0b5c163 100644
--- a/after/ftplugin/c.lua
+++ b/after/ftplugin/c.lua
@@ -16,4 +16,7 @@ map("n", ",i", function()
vim.cmd("normal ''")
end, { desc = "Include header for word under cursor" })
map("n", ",f", mapcmd("CF"), { desc = "Toggle formatting" })
-vim.o.commentstring = "// %s"
+
+vim.opt.commentstring = "// %s"
+-- disable indent in switch statement
+vim.opt.cinoptions = "l1"
diff --git a/after/plugin/conform.lua b/after/plugin/conform.lua
index 7a8bbce..643743f 100644
--- a/after/plugin/conform.lua
+++ b/after/plugin/conform.lua
@@ -12,42 +12,42 @@ conform.setup({
},
})
-conform.formatters["clang-format"] = {
- prepend_args = {
- "--style",
- "{"
- .. "IndentWidth: 4, "
- .. "AlignAfterOpenBracket: BlockIndent, "
- .. "AlignArrayOfStructures: Right, "
- .. "BreakBeforeBraces: Linux, "
- .. "PointerAlignment: Left,"
- .. "AllowShortIfStatementsOnASingleLine: true, "
- .. "AllowShortLoopsOnASingleLine: true, "
- .. "AllowAllArgumentsOnNextLine: true, "
- .. "AllowShortCaseLabelsOnASingleLine: true, "
- .. "BreakAfterReturnType: AllDefinitions, "
- .. "ColumnLimit: "
- .. vim.o.tw
- .. "}",
- },
-}
+-- conform.formatters["clang-format"] = {
+-- prepend_args = {
+-- "--style",
+-- "{"
+-- .. "IndentWidth: 4, "
+-- .. "AlignAfterOpenBracket: BlockIndent, "
+-- .. "AlignArrayOfStructures: Right, "
+-- .. "BreakBeforeBraces: Linux, "
+-- .. "PointerAlignment: Left,"
+-- .. "AllowShortIfStatementsOnASingleLine: true, "
+-- .. "AllowShortLoopsOnASingleLine: true, "
+-- .. "AllowAllArgumentsOnNextLine: true, "
+-- .. "AllowShortCaseLabelsOnASingleLine: true, "
+-- .. "AlwaysBreakAfterReturnType: AllDefinitions, "
+-- .. "ColumnLimit: "
+-- .. vim.o.tw
+-- .. "}",
+-- },
+-- }
--- ID of autocmd for CFormat
-vim.b.CFormatID = nil
--- Enable formatting on save for C only when using the :CFormat command
-vim.api.nvim_create_user_command("CFormat", function()
- if vim.b.CFormatID == nil then
- vim.b.CFormatID = vim.api.nvim_create_autocmd("BufWritePre", {
- buffer = 0,
- callback = function()
- conform.format({ formatters = { "clang-format" } })
- end,
- })
- conform.format({ formatters = { "clang-format" } })
- print("Auto formatting enabled.")
- else
- vim.api.nvim_del_autocmd(vim.b.CFormatID)
- print("Auto formatting disabled.")
- vim.b.CFormatID = nil
- end
-end, {})
+-- -- ID of autocmd for CFormat
+-- vim.b.CFormatID = nil
+-- -- Enable formatting on save for C only when using the :CFormat command
+-- vim.api.nvim_create_user_command("CFormat", function()
+-- if vim.b.CFormatID == nil then
+-- vim.b.CFormatID = vim.api.nvim_create_autocmd("BufWritePre", {
+-- buffer = 0,
+-- callback = function()
+-- conform.format({ formatters = { "clang-format" } })
+-- end,
+-- })
+-- conform.format({ formatters = { "clang-format" } })
+-- print("Auto formatting enabled.")
+-- else
+-- vim.api.nvim_del_autocmd(vim.b.CFormatID)
+-- print("Auto formatting disabled.")
+-- vim.b.CFormatID = nil
+-- end
+-- end, {})
diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua
deleted file mode 100644
index 4b88ca9..0000000
--- a/after/plugin/luasnip.lua
+++ /dev/null
@@ -1,63 +0,0 @@
-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/init.lua b/init.lua
index 320638f..fce222b 100644
--- a/init.lua
+++ b/init.lua
@@ -1,5 +1,5 @@
require("config.lazy")
require("config.set")
require("config.map")
-require("config.lsp")
+-- require("config.lsp")
require("config.autocmds")
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, {})