From af0a29b20d793eb3dac82f8c32e64b59d6849775 Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 18 Nov 2024 21:49:33 +1300 Subject: [PATCH] update --- clang/.clang-format | 25 ++++++++++++++++ nvim/init.lua | 72 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 92 insertions(+), 5 deletions(-) create mode 100644 clang/.clang-format diff --git a/clang/.clang-format b/clang/.clang-format new file mode 100644 index 0000000..c17e64a --- /dev/null +++ b/clang/.clang-format @@ -0,0 +1,25 @@ +BasedOnStyle: WebKit +IndentWidth: 4 +TabWidth: 4 +UseTab: Never +AlignConsecutiveDeclarations: false +AlignConsecutiveAssignments: false +AlignTrailingComments: true +ColumnLimit: 105 +BreakBeforeBraces: Attach +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortLambdasOnASingleLine: false +PointerAlignment: Left +SpaceBeforeParens: Never +SpacesInParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpaceAfterCStyleCast: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeSquareBrackets: false +SpacesBeforeTrailingComments: 2 +PenaltyBreakAssignment: 1000 +NamespaceIndentation: All + diff --git a/nvim/init.lua b/nvim/init.lua index 63e61d1..68e0d0f 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -7,6 +7,9 @@ vim.opt.shiftwidth = 4 vim.opt.smarttab = true vim.opt.autoindent = true vim.opt.mouse = "a" +vim.opt.undofile = true +vim.opt.ignorecase = true +vim.opt.smartcase = true vim.cmd("colorscheme habamax") @@ -24,7 +27,19 @@ local plugins = { } local servers = { - clangd = {} + clangd = { cmd = { "clangd", "-header-insertion=never" } }, + gopls = {}, + nim_langserver = {}, + rust_analyzer = {}, + cssls = { + cmd = { "vscode-css-language-server", "--stdio" } + }, + html = { + cmd = { "vscode-html-language-server", "--stdio" } + }, + jsonls = { + cmd = { "vscode-json-language-server", "--stdio" } + } } -- Install plugin manager @@ -37,12 +52,11 @@ if not vim.loop.fs_stat(mini_path) then vim.cmd("packadd mini.nvim | helptags ALL") end + require("mini.deps").setup({ path = { package = path_package } }) -require("mini.sessions").setup({ - autoread = true, - autowrite = true -}) +-- mini.completion is missing snippet support so waiting for that, once added can get rid of cmp +-- require("mini.completion").setup() -- is Ctrl+/ local comment_keybind = "" @@ -110,3 +124,51 @@ vim.keymap.set({ "i", "s" }, "", function() return "" end end, { expr = true }) + +vim.keymap.set({ "n" }, "gd", function() + vim.lsp.buf.definition() +end) + +vim.keymap.set({ "n" }, "a", function() + vim.lsp.buf.code_action() +end) + +vim.keymap.set({ "n" }, "e", function() + vim.diagnostic.open_float() +end) + +-- Session saving and restoring +local session_file = vim.fn.stdpath("data") .. "/sessions/" .. vim.fn.fnamemodify(vim.fn.getcwd(), ':t') .. "/session.vim" +vim.api.nvim_create_autocmd("VimLeavePre", { + pattern = "*", + callback = function() + vim.fn.mkdir(vim.fn.fnamemodify(session_file, ":h"), "p") + vim.cmd("mksession! " .. session_file) + vim.v.this_session = session_file + end, +}) + +vim.api.nvim_create_autocmd("VimEnter", { + nested = true, + once = true, + callback = function() + if vim.fn.filereadable(session_file) == 1 and #vim.fn.argv() == 0 then + vim.cmd("silent! %bwipeout!") + vim.cmd("silent! source " .. session_file) + vim.v.this_session = session_file + end + end +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "c", "lua", "md", "vim" }, + callback = function() + vim.treesitter.start() + end +}) + +vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() + vim.lsp.buf.format({ async = false }) + end +})