From e66373dda678f0136abd4e30e25e9cb592f9e697 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Mon, 23 Sep 2024 13:48:11 +0200 Subject: [PATCH] nixvim: add default tab behavior --- home/common/programs/nixvim/core.nix | 1 - home/common/programs/nixvim/plugins/lsp.nix | 153 +++++++++++--------- 2 files changed, 82 insertions(+), 72 deletions(-) diff --git a/home/common/programs/nixvim/core.nix b/home/common/programs/nixvim/core.nix index 6be779e..33782e0 100644 --- a/home/common/programs/nixvim/core.nix +++ b/home/common/programs/nixvim/core.nix @@ -19,7 +19,6 @@ globals.mapleader = " "; opts = { - smartindent = false; relativenumber = true; clipboard = "unnamedplus"; }; diff --git a/home/common/programs/nixvim/plugins/lsp.nix b/home/common/programs/nixvim/plugins/lsp.nix index 6e83e46..63b6b4e 100644 --- a/home/common/programs/nixvim/plugins/lsp.nix +++ b/home/common/programs/nixvim/plugins/lsp.nix @@ -1,6 +1,13 @@ { ... }: { programs.nixvim = { + opts = { + tabstop = 4; + shiftwidth = 4; + softtabstop = 0; + expandtab = true; + smartindent = true; + }; plugins = { treesitter = { enable = true; @@ -11,9 +18,7 @@ custom_captures = { }; enable = true; }; - indent = { - enable = true; - }; + indent.enable = false; folding = true; parser_install_dir = { __raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'treesitter')"; @@ -37,14 +42,14 @@ indent-blankline = { enable = true; settings = - { - exclude = { - buftypes = [ - "terminal" + { + exclude = { + buftypes = [ + "terminal" "quickfix" - ]; - filetypes = [ - "" + ]; + filetypes = [ + "" "checkhealth" "help" "lspinfo" @@ -52,17 +57,17 @@ "TelescopePrompt" "TelescopeResults" "yaml" - ]; - }; - indent = { - char = "│"; - }; - scope = { - show_end = false; - show_exact_scope = true; - show_start = false; - }; + ]; }; + indent = { + char = "│"; + }; + scope = { + show_end = false; + show_exact_scope = true; + show_start = false; + }; + }; }; lsp = { enable = true; @@ -70,7 +75,13 @@ gopls.enable = true; nixd.enable = true; lua-ls.enable = true; - clangd.enable = true; + clangd = { + enable = true; + cmd = [ + "clangd" + "--fallback-style=webkit" + ]; + }; }; keymaps = { lspBuf = { @@ -89,34 +100,34 @@ }; }; extra = [ - { - action = "LspStop"; - key = "lx"; - options = { - desc = "Stop LSP"; - }; - } - { - action = "LspStart"; - key = "ls"; - options = { - desc = "Start LSP"; - }; - } - { - action = "LspRestart"; - key = "lr"; - options = { - desc = "Restart LSP"; - }; - } - { - action = "Telescope lsp_definitions"; - key = "gd"; - options = { - desc = "Go to definitions"; - }; - } + { + action = "LspStop"; + key = "lx"; + options = { + desc = "Stop LSP"; + }; + } + { + action = "LspStart"; + key = "ls"; + options = { + desc = "Start LSP"; + }; + } + { + action = "LspRestart"; + key = "lr"; + options = { + desc = "Restart LSP"; + }; + } + { + action = "Telescope lsp_definitions"; + key = "gd"; + options = { + desc = "Go to definitions"; + }; + } ]; }; postConfig = '' @@ -139,30 +150,30 @@ "" = "cmp.mapping.confirm({ select = true })"; "" = '' cmp.mapping(function (fallback) - local luasnip = require('luasnip') - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, {'i', 's'}) - ''; + local luasnip = require('luasnip') + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, {'i', 's'}) + ''; "" = '' cmp.mapping(function (fallback) - local luasnip = require('luasnip') - if luasnip.expandable() then - luasnip.expand() - elseif cmp.visible() then - cmp.select_next_item() - elseif luasnip.jumpable(1) then - luasnip.jump(1) - else - fallback() - end - end, {'i', 's'}) - ''; + local luasnip = require('luasnip') + if luasnip.expandable() then + luasnip.expand() + elseif cmp.visible() then + cmp.select_next_item() + elseif luasnip.jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, {'i', 's'}) + ''; }; sources =