From 8b5b76392049a2f5383890ed8834fa86ddf3ebd8 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Sun, 11 Jun 2023 02:33:10 -0400 Subject: [PATCH] neovim tinkering --- homeConfig/modules/neovim/config/init.nix | 31 ------- .../config/lazyvim/lua/config/autocmds.lua | 21 ++--- .../config/lazyvim/lua/config/keymaps.lua | 6 +- .../neovim/config/lazyvim/lua/config/lazy.lua | 2 +- .../config/lazyvim/lua/config/options.lua | 15 +++ .../config/lazyvim/lua/plugins/core.lua | 3 + .../modules/neovim/config/plugins/backup.nix | 19 ---- .../modules/neovim/config/plugins/default.nix | 9 -- .../neovim/config/plugins/editing/default.nix | 8 -- .../neovim/config/plugins/lazyvim/default.nix | 6 -- .../neovim/config/plugins/lsp/default.nix | 93 ------------------- .../neovim/config/plugins/luasnip/default.nix | 26 ------ .../neovim/config/plugins/theme/default.nix | 54 ----------- .../neovim/config/plugins/theme/github.nix | 56 ----------- .../neovim/config/plugins/tools/default.nix | 9 -- .../config/plugins/treesitter/default.nix | 17 ---- homeConfig/modules/utils/default.nix | 7 +- 17 files changed, 36 insertions(+), 346 deletions(-) delete mode 100644 homeConfig/modules/neovim/config/init.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/backup.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/default.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/editing/default.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/lazyvim/default.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/lsp/default.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/luasnip/default.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/theme/default.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/theme/github.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/tools/default.nix delete mode 100644 homeConfig/modules/neovim/config/plugins/treesitter/default.nix diff --git a/homeConfig/modules/neovim/config/init.nix b/homeConfig/modules/neovim/config/init.nix deleted file mode 100644 index c423a19..0000000 --- a/homeConfig/modules/neovim/config/init.nix +++ /dev/null @@ -1,31 +0,0 @@ -'' - -vim.o.relativenumber = true -vim.o.number = true -vim.cmd('highlight LineNr ctermfg=DarkGray') - -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.expandtab = true - -vim.o.clipboard = "unnamedplus" - -vim.o.foldmethod = "indent" -vim.o.foldlevelstart = 99 - -vim.cmd([[ - au BufRead,BufNewFile *.purs set filetype=purescript -]]) - - -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - -- Disable virtual_text - virtual_text = false, -}) - -vim.api.nvim_set_keymap('n', '', 'zz', {noremap = true}) -vim.api.nvim_set_keymap('n', '', 'zz', {noremap = true}) -vim.api.nvim_set_keymap('n', '', 'zz', {noremap = true}) -vim.api.nvim_set_keymap('n', '', 'zz', {noremap = true}) - -'' diff --git a/homeConfig/modules/neovim/config/lazyvim/lua/config/autocmds.lua b/homeConfig/modules/neovim/config/lazyvim/lua/config/autocmds.lua index 631f7cd..4d1c1bf 100644 --- a/homeConfig/modules/neovim/config/lazyvim/lua/config/autocmds.lua +++ b/homeConfig/modules/neovim/config/lazyvim/lua/config/autocmds.lua @@ -2,11 +2,6 @@ -- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua -- Add any additional autocmds here -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.softtabstop = 2 -vim.opt.expandtab = true - local lsp = require("lsp-zero").preset({}) lsp.on_attach(function(client, bufnr) @@ -46,7 +41,7 @@ cmp.setup({ }, sources = { { name = "nvim_lsp" }, - -- { name = "luasnip" }, + { name = "luasnip" }, -- other sources... }, -- other configurations... @@ -72,14 +67,14 @@ cmp.setup({ if vim.api.nvim_get_mode().mode == "c" then return true else - return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment") + return not context.in_treesitter_capture("comment") and not context.in_syntax_group("comment") end end, mapping = { - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- you could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() -- they way you will only jump inside the snippet region elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() @@ -90,7 +85,7 @@ cmp.setup({ end end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then @@ -100,16 +95,14 @@ cmp.setup({ end end, { "i", "s" }), - [""] = cmp.mapping({ + [""] = cmp.mapping({ i = function(fallback) if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + cmp.confirm({ behavior = cmp.confirmbehavior.replace, select = true }) else fallback() end end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), }), }, }) diff --git a/homeConfig/modules/neovim/config/lazyvim/lua/config/keymaps.lua b/homeConfig/modules/neovim/config/lazyvim/lua/config/keymaps.lua index 0aa0b8a..8b13dd7 100644 --- a/homeConfig/modules/neovim/config/lazyvim/lua/config/keymaps.lua +++ b/homeConfig/modules/neovim/config/lazyvim/lua/config/keymaps.lua @@ -2,5 +2,7 @@ -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here -vim.api.nvim_set_keymap('n', '', 'zz', { noremap = true }) -vim.api.nvim_set_keymap('n', '', 'zz', { noremap = true }) +vim.keymap.set("n", "", "zz", { silent = true }) +vim.keymap.set("n", "", "zz", { silent = true }) +vim.keymap.set("n", "", "w", { silent = true }) +vim.keymap.set("n", "", "b", { silent = true }) diff --git a/homeConfig/modules/neovim/config/lazyvim/lua/config/lazy.lua b/homeConfig/modules/neovim/config/lazyvim/lua/config/lazy.lua index 6b501dc..8e709a3 100644 --- a/homeConfig/modules/neovim/config/lazyvim/lua/config/lazy.lua +++ b/homeConfig/modules/neovim/config/lazyvim/lua/config/lazy.lua @@ -11,7 +11,7 @@ require("lazy").setup({ -- add LazyVim and import its plugins { "LazyVim/LazyVim", import = "lazyvim.plugins" }, -- import any extras modules here - { import = "lazyvim.plugins.extras.ui.mini-animate" }, + -- { import = "lazyvim.plugins.extras.ui.mini-animate" }, -- import/override with your plugins { import = "plugins" }, }, diff --git a/homeConfig/modules/neovim/config/lazyvim/lua/config/options.lua b/homeConfig/modules/neovim/config/lazyvim/lua/config/options.lua index 3ea1454..418907d 100644 --- a/homeConfig/modules/neovim/config/lazyvim/lua/config/options.lua +++ b/homeConfig/modules/neovim/config/lazyvim/lua/config/options.lua @@ -1,3 +1,18 @@ -- Options are automatically loaded before lazy.nvim startup -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua -- Add any additional options here + +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.softtabstop = 2 +vim.opt.expandtab = true +vim.opt.smartindent = true + +vim.opt.ignorecase = true +vim.opt.smartcase = true + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undofile = true + +vim.opt.guicursor = "n-v-c:block,i:block,r:block" diff --git a/homeConfig/modules/neovim/config/lazyvim/lua/plugins/core.lua b/homeConfig/modules/neovim/config/lazyvim/lua/plugins/core.lua index d31c0f3..325ce61 100644 --- a/homeConfig/modules/neovim/config/lazyvim/lua/plugins/core.lua +++ b/homeConfig/modules/neovim/config/lazyvim/lua/plugins/core.lua @@ -25,7 +25,10 @@ return { -- Autocompletion { "hrsh7th/nvim-cmp" }, -- Required + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, { "hrsh7th/cmp-nvim-lsp" }, -- Required + { "L3MON4D3/LuaSnip" }, -- Required }, }, diff --git a/homeConfig/modules/neovim/config/plugins/backup.nix b/homeConfig/modules/neovim/config/plugins/backup.nix deleted file mode 100644 index 12ba519..0000000 --- a/homeConfig/modules/neovim/config/plugins/backup.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ pkgs, lib, ... }: - -let - theme = import ./theme; - treesitter = import ./treesitter; - editing = import ./editing; - lsp = import ./lsp; - luasnip = import ./luasnip; - tools = import ./tools; - -in -builtins.concatMap (dir: dir { inherit pkgs lib; }) [ - theme - treesitter - editing - lsp - luasnip - tools -] diff --git a/homeConfig/modules/neovim/config/plugins/default.nix b/homeConfig/modules/neovim/config/plugins/default.nix deleted file mode 100644 index 0bc6603..0000000 --- a/homeConfig/modules/neovim/config/plugins/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkgs, lib, ... }: - -let - lazyvim = import ./lazyvim; - -in -builtins.concatMap (dir: dir { inherit pkgs lib; }) [ - lazyvim -] diff --git a/homeConfig/modules/neovim/config/plugins/editing/default.nix b/homeConfig/modules/neovim/config/plugins/editing/default.nix deleted file mode 100644 index 81886ea..0000000 --- a/homeConfig/modules/neovim/config/plugins/editing/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ pkgs, ... }: - -with pkgs.vimPlugins; -[ - { plugin = indent-blankline-nvim; } - { plugin = auto-pairs; } - { plugin = vim-css-color; } -] diff --git a/homeConfig/modules/neovim/config/plugins/lazyvim/default.nix b/homeConfig/modules/neovim/config/plugins/lazyvim/default.nix deleted file mode 100644 index 7286cd4..0000000 --- a/homeConfig/modules/neovim/config/plugins/lazyvim/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ pkgs, ... }: - -with pkgs.vimPlugins; -[ - { plugin = LazyVim; } -] diff --git a/homeConfig/modules/neovim/config/plugins/lsp/default.nix b/homeConfig/modules/neovim/config/plugins/lsp/default.nix deleted file mode 100644 index 5619496..0000000 --- a/homeConfig/modules/neovim/config/plugins/lsp/default.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ pkgs, ... }: - -with pkgs.vimPlugins; -[ - { plugin = lsp-zero-nvim; - config = '' - lua << EOF - local lsp = require('lsp-zero').preset({}) - - lsp.on_attach(function(client, bufnr) - lsp.default_keymaps({buffer = bufnr}) - end) - - lsp.setup_servers({ - "tsserver", - "eslint", - "hls", - "pyright", - "nil_ls", - "cssls", - "html", - "jsonls", - "diagnosticls", - "lua_ls", - "marksman", - "purescriptls", - "tailwindcss", - "bashls", - }) - - lsp.setup() - EOF - ''; - } - - { plugin = null-ls-nvim; } - { plugin = nvim-lspconfig; } - { plugin = cmp-nvim-lsp; } - - { plugin = nvim-cmp; - config = '' - lua << EOF - local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - local luasnip = require("luasnip") - local cmp = require'cmp' - - cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - end, - }, - - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - - enabled = function() - -- disable completion in comments - local context = require("cmp.config.context") - -- keep command mode completion enabled when cursor is in a comment - if vim.api.nvim_get_mode().mode == "c" then - return true - else - return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment") - end - 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' }, -- For luasnip users. - }, { - { name = 'buffer' }, - }) - }) - EOF - ''; - } -] diff --git a/homeConfig/modules/neovim/config/plugins/luasnip/default.nix b/homeConfig/modules/neovim/config/plugins/luasnip/default.nix deleted file mode 100644 index 65c25f9..0000000 --- a/homeConfig/modules/neovim/config/plugins/luasnip/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ pkgs, ... }: - -with pkgs.vimPlugins; -[ - { plugin = luasnip; - config = '' - lua << EOF - local luasnip = require 'luasnip' - - -- Expand or jump in a snippet - vim.api.nvim_set_keymap('i', '', 'lua return luasnip.expand_or_jumpable() and \'luasnip-expand-or-jump\' or \'\'', { expr = true, silent = true }) - - -- Jump backwards in a snippet - vim.api.nvim_set_keymap('i', '', 'lua luasnip.jump(-1)', {silent = true}) - - -- Keymaps for Select mode - vim.api.nvim_set_keymap('s', '', 'lua require(\'luasnip\').jump(1)', {silent = true}) - vim.api.nvim_set_keymap('s', '', 'lua require(\'luasnip\').jump(-1)', {silent = true}) - - -- Changing choices in choiceNodes - vim.api.nvim_set_keymap('i', '', 'lua return luasnip.choice_active() and \'luasnip-next-choice\' or \'\'', { expr = true, silent = true }) - vim.api.nvim_set_keymap('s', '', 'lua return luasnip.choice_active() and \'luasnip-next-choice\' or \'\'', { expr = true, silent = true }) - EOF - ''; - } -] diff --git a/homeConfig/modules/neovim/config/plugins/theme/default.nix b/homeConfig/modules/neovim/config/plugins/theme/default.nix deleted file mode 100644 index 179206f..0000000 --- a/homeConfig/modules/neovim/config/plugins/theme/default.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ pkgs, ... }: - -with pkgs.vimPlugins; -[ - { plugin = catppuccin-nvim; - config = '' - lua << EOF - require("catppuccin").setup({ - flavour = "mocha", -- latte, frappe, macchiato, mocha - background = { -- :h background - light = "latte", - dark = "mocha", - }, - transparent_background = true, -- disables setting the background color. - show_end_of_buffer = false, -- shows the '~' characters after the end of buffers - term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`) - dim_inactive = { - enabled = false, -- dims the background color of inactive window - shade = "dark", - percentage = 0.15, -- percentage of the shade to apply to the inactive window - }, - no_italic = false, -- Force no italic - no_bold = false, -- Force no bold - no_underline = false, -- Force no underline - styles = { -- Handles the styles of general hi groups (see `:h highlight-args`): - comments = { "italic" }, -- Change the style of comments - conditionals = { "italic" }, - loops = {}, - functions = {}, - keywords = {}, - strings = {}, - variables = {}, - numbers = {}, - booleans = {}, - properties = {}, - types = {}, - operators = {}, - }, - color_overrides = {}, - custom_highlights = {}, - integrations = { - cmp = true, - gitsigns = true, - nvimtree = true, - telescope = true, - notify = false, - mini = false, - }, - }) - vim.cmd.colorscheme "catppuccin" - local mocha = require("catppuccin.palettes").get_palette "mocha" - ''; - } -] diff --git a/homeConfig/modules/neovim/config/plugins/theme/github.nix b/homeConfig/modules/neovim/config/plugins/theme/github.nix deleted file mode 100644 index 775821d..0000000 --- a/homeConfig/modules/neovim/config/plugins/theme/github.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ pkgs, lib, ... }: - -let - - panvimdoc = pkgs.fetchFromGitHub { - owner = "kdheepak"; - repo = "panvimdoc"; - rev = "v3.0.6"; - sha256 = "0smij72mpd1lm6akjzkmh2z76xfgn86n7n1ah36fz16p1krc1nwv"; - }; - github-theme = pkgs.stdenv.mkDerivation { - pname = "github-theme"; - version = "1.0.0"; - src = pkgs.fetchFromGitHub { - owner = "projekt0n"; - repo = "github-nvim-theme"; - rev = "v1.0.0"; - sha256 = "1b9fac3ajqr9i5291k3z3pgrh3l08ga1ghdw05s1nq3xvbzcicn5"; - }; - buildInputs = [ pkgs.makeWrapper ]; - - buildPhase = '' - # replace misc/panvimdoc with our pre-fetched version - rm -rf misc/panvimdoc - ln -s ${panvimdoc} misc/panvimdoc - - # carry on with the build as normal - make - ''; - - installPhase = '' - # install the plugin to $out - mkdir -p $out - cp -r * $out - ''; - - meta = with lib; { - description = "A dark theme for Neovim"; - homepage = "https://github.com/projekt0n/github-nvim-theme"; - license = licenses.mit; - platforms = platforms.all; - }; - }; - -in -[ - { - plugin = github-theme; - config = '' - lua << EOF - vim.cmd('colorscheme github_dark_high_contrast') - EOF - ''; - } -] - diff --git a/homeConfig/modules/neovim/config/plugins/tools/default.nix b/homeConfig/modules/neovim/config/plugins/tools/default.nix deleted file mode 100644 index c9fbe7d..0000000 --- a/homeConfig/modules/neovim/config/plugins/tools/default.nix +++ /dev/null @@ -1,9 +0,0 @@ - { pkgs, ... }: - -with pkgs.vimPlugins; -[ - { plugin = lazygit-nvim; } - { plugin = nvim-web-devicons; } - { plugin = lualine-nvim; } - { plugin = neo-tree-nvim; } -] diff --git a/homeConfig/modules/neovim/config/plugins/treesitter/default.nix b/homeConfig/modules/neovim/config/plugins/treesitter/default.nix deleted file mode 100644 index f550aa8..0000000 --- a/homeConfig/modules/neovim/config/plugins/treesitter/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, ...}: - -with pkgs.vimPlugins; - -[ - { plugin = nvim-treesitter.withAllGrammars; - config = '' - lua << EOF - require'nvim-treesitter.configs'.setup { - highlight = { - enable = true, - }, - } - EOF - ''; - } -] diff --git a/homeConfig/modules/utils/default.nix b/homeConfig/modules/utils/default.nix index 3fd1c07..7a76a65 100644 --- a/homeConfig/modules/utils/default.nix +++ b/homeConfig/modules/utils/default.nix @@ -8,7 +8,12 @@ in { options.modules.utils = { enable = mkEnableOption "utils"; }; config = mkIf cfg.enable { - services.syncthing.enable = true; +# services.syncthing = { +# enable = true; +# extraOptions = [ +# "--gui-adddress:8384" +# ]; +# }; home.packages = with pkgs; [ wget curl tree neofetch