neovim tinkering

This commit is contained in:
Bryan Ramos 2023-06-11 02:33:10 -04:00
parent 5551b085c0
commit 8b5b763920
17 changed files with 36 additions and 346 deletions

View file

@ -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', '<PageUp>', '<PageUp>zz', {noremap = true})
vim.api.nvim_set_keymap('n', '<PageDown>', '<PageDown>zz', {noremap = true})
vim.api.nvim_set_keymap('n', '<C-U>', '<C-U>zz', {noremap = true})
vim.api.nvim_set_keymap('n', '<C-D>', '<C-D>zz', {noremap = true})
''

View file

@ -2,11 +2,6 @@
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua -- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here -- 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({}) local lsp = require("lsp-zero").preset({})
lsp.on_attach(function(client, bufnr) lsp.on_attach(function(client, bufnr)
@ -46,7 +41,7 @@ cmp.setup({
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
-- { name = "luasnip" }, { name = "luasnip" },
-- other sources... -- other sources...
}, },
-- other configurations... -- other configurations...
@ -72,14 +67,14 @@ cmp.setup({
if vim.api.nvim_get_mode().mode == "c" then if vim.api.nvim_get_mode().mode == "c" then
return true return true
else 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
end, end,
mapping = { mapping = {
["<Tab>"] = cmp.mapping(function(fallback) ["<tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() 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 -- they way you will only jump inside the snippet region
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
@ -90,7 +85,7 @@ cmp.setup({
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<s-tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
@ -100,16 +95,14 @@ cmp.setup({
end end
end, { "i", "s" }), end, { "i", "s" }),
["<CR>"] = cmp.mapping({ ["<cr>"] = cmp.mapping({
i = function(fallback) i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then 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 else
fallback() fallback()
end end
end, end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
}), }),
}, },
}) })

View file

@ -2,5 +2,7 @@
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here -- Add any additional keymaps here
vim.api.nvim_set_keymap('n', '<C-U>', '<C-U>zz', { noremap = true }) vim.keymap.set("n", "<C-K>", "<C-U>zz", { silent = true })
vim.api.nvim_set_keymap('n', '<C-D>', '<C-D>zz', { noremap = true }) vim.keymap.set("n", "<C-J>", "<C-D>zz", { silent = true })
vim.keymap.set("n", "<C-L>", "w", { silent = true })
vim.keymap.set("n", "<C-H>", "b", { silent = true })

View file

@ -11,7 +11,7 @@ require("lazy").setup({
-- add LazyVim and import its plugins -- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" }, { "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import any extras modules here -- 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/override with your plugins
{ import = "plugins" }, { import = "plugins" },
}, },

View file

@ -1,3 +1,18 @@
-- Options are automatically loaded before lazy.nvim startup -- 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 -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here -- 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"

View file

@ -25,7 +25,10 @@ return {
-- Autocompletion -- Autocompletion
{ "hrsh7th/nvim-cmp" }, -- Required { "hrsh7th/nvim-cmp" }, -- Required
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "hrsh7th/cmp-nvim-lsp" }, -- Required { "hrsh7th/cmp-nvim-lsp" }, -- Required
{ "L3MON4D3/LuaSnip" }, -- Required { "L3MON4D3/LuaSnip" }, -- Required
}, },
}, },

View file

@ -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
]

View file

@ -1,9 +0,0 @@
{ pkgs, lib, ... }:
let
lazyvim = import ./lazyvim;
in
builtins.concatMap (dir: dir { inherit pkgs lib; }) [
lazyvim
]

View file

@ -1,8 +0,0 @@
{ pkgs, ... }:
with pkgs.vimPlugins;
[
{ plugin = indent-blankline-nvim; }
{ plugin = auto-pairs; }
{ plugin = vim-css-color; }
]

View file

@ -1,6 +0,0 @@
{ pkgs, ... }:
with pkgs.vimPlugins;
[
{ plugin = LazyVim; }
]

View file

@ -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({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = 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
'';
}
]

View file

@ -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', '<Tab>', '<cmd>lua return luasnip.expand_or_jumpable() and \'<Plug>luasnip-expand-or-jump\' or \'<Tab>\'<CR>', { expr = true, silent = true })
-- Jump backwards in a snippet
vim.api.nvim_set_keymap('i', '<S-Tab>', '<cmd>lua luasnip.jump(-1)<CR>', {silent = true})
-- Keymaps for Select mode
vim.api.nvim_set_keymap('s', '<Tab>', '<cmd>lua require(\'luasnip\').jump(1)<CR>', {silent = true})
vim.api.nvim_set_keymap('s', '<S-Tab>', '<cmd>lua require(\'luasnip\').jump(-1)<CR>', {silent = true})
-- Changing choices in choiceNodes
vim.api.nvim_set_keymap('i', '<C-E>', '<cmd>lua return luasnip.choice_active() and \'<Plug>luasnip-next-choice\' or \'<C-E>\'<CR>', { expr = true, silent = true })
vim.api.nvim_set_keymap('s', '<C-E>', '<cmd>lua return luasnip.choice_active() and \'<Plug>luasnip-next-choice\' or \'<C-E>\'<CR>', { expr = true, silent = true })
EOF
'';
}
]

View file

@ -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"
'';
}
]

View file

@ -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
'';
}
]

View file

@ -1,9 +0,0 @@
{ pkgs, ... }:
with pkgs.vimPlugins;
[
{ plugin = lazygit-nvim; }
{ plugin = nvim-web-devicons; }
{ plugin = lualine-nvim; }
{ plugin = neo-tree-nvim; }
]

View file

@ -1,17 +0,0 @@
{ pkgs, ...}:
with pkgs.vimPlugins;
[
{ plugin = nvim-treesitter.withAllGrammars;
config = ''
lua << EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
}
EOF
'';
}
]

View file

@ -8,7 +8,12 @@ in
{ options.modules.utils = { enable = mkEnableOption "utils"; }; { options.modules.utils = { enable = mkEnableOption "utils"; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.syncthing.enable = true; # services.syncthing = {
# enable = true;
# extraOptions = [
# "--gui-adddress:8384"
# ];
# };
home.packages = with pkgs; [ home.packages = with pkgs; [
wget curl tree neofetch wget curl tree neofetch