feat: I am keeping neovim config in an independent repo

main
Ricard Illa 2023-08-07 15:55:15 +02:00
parent de13ab6b0e
commit d671eee239
Signed by: rilla
GPG Key ID: 525307BD467E4205
22 changed files with 6 additions and 593 deletions

View File

@ -34,13 +34,13 @@
]; ];
extraPython3Packages = pyPkgs: with pyPkgs; [ pylint ]; extraPython3Packages = pyPkgs: with pyPkgs; [ pylint ];
# plugins = [ pkgs.vimPlugins.lazy-nvim ]; # plugins = [ pkgs.vimPlugins.lazy-nvim ];
extraLuaConfig = builtins.readFile ./init.lua; # extraLuaConfig = builtins.readFile ./init.lua;
};
home.file.lua = {
recursive = true;
source = ./lua;
target = "/.config/nvim/lua";
}; };
# home.file.lua = {
# recursive = true;
# source = ./lua;
# target = "/.config/nvim/lua";
# };
home.packages = [ pkgs.neovide ]; home.packages = [ pkgs.neovide ];

View File

@ -1,98 +0,0 @@
-- luacheck: globals vim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = ","
vim.g.maplocaleader = "\\"
require("lazy").setup('plugins')
vim.opt.wrap = false
vim.opt.number = true
vim.opt.compatible = false
vim.opt.mouse = "a" -- mouse support
vim.opt.showcmd = true -- show incomplete cmds down the bottom
vim.opt.showmode = true -- show current mode
vim.opt.showmatch = true -- set show matching parenthesis
vim.opt.visualbell = true -- no sounds
vim.opt.autoread = true -- reload files changed outside of vim
vim.opt.backspace = [[indent,eol,start]] -- allow backspacing over everything in insert mode
vim.opt.ignorecase = true -- ignore case when searching
vim.opt.shiftround = true -- use multiple of shiftwidth when indenting with '<' and '>'
vim.opt.smartcase = true -- ignore case if searching pattern is all lowecase, case-sensitive otherwise
vim.opt.smarttab = true -- insert tabs on the start of a line according to shiftwidth, not tabstop
vim.opt.hlsearch = true -- highlight search terms
vim.opt.incsearch = true -- show search matches as you type
vim.opt.hidden = true
vim.opt.ruler = true
vim.opt.clipboard = "unnamed" -- system clipboard
vim.opt.colorcolumn = "80"
-- vim.cmd("syntax on")
vim.cmd("filetype plugin on")
if vim.fn.has("multi_byte") == 1 and vim.o.encoding == "utf-8" then
vim.opt.listchars = [[tab:▸ ,extends:,precedes:,nbsp:±,trail:…]]
else
vim.opt.listchars = [[tab:> ,extends:>,precedes:<,nbsp:.,trail:_]]
end
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.api.nvim_set_keymap('n', "<A-r>", "<C-w>r", {})
vim.api.nvim_set_keymap('n', "<A-1>", "1gt", {})
vim.api.nvim_set_keymap('n', "<A-2>", "2gt", {})
vim.api.nvim_set_keymap('n', "<A-3>", "3gt", {})
vim.api.nvim_set_keymap('n', "<A-4>", "4gt", {})
vim.api.nvim_set_keymap('n', "<A-5>", "5gt", {})
vim.api.nvim_set_keymap('n', "<A-6>", "6gt", {})
vim.api.nvim_set_keymap('n', "<A-7>", "7gt", {})
vim.api.nvim_set_keymap('n', "<A-8>", "8gt", {})
vim.api.nvim_set_keymap('n', "<A-9>", ":tablast<cr>", {})
vim.api.nvim_set_keymap('n', "<C-l>", ":nohl<CR><C-l>", { noremap = true })
-- todo: try to do it with `vim.api.nvim_set_hl`
vim.cmd("hi CursorLine cterm=NONE,underline ctermbg=NONE") -- highlight line when in insert mode
vim.opt.timeoutlen = 1000
vim.opt.ttimeoutlen = 0
vim.cmd("autocmd InsertEnter * :set cursorline")
vim.cmd("autocmd InsertLeave * :set nocursorline")
-- indentation
vim.cmd("filetype indent on")
vim.opt.softtabstop = 4
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.autoindent = true
vim.opt.copyindent = true
-- folds
vim.opt.foldmethod = "indent"
vim.opt.foldnestmax = 3
vim.opt.foldenable = false
vim.opt.termguicolors = true
-- vim.g.markdown_syntax_conceal = 0
vim.opt.updatetime = 100 -- to make gigutter more responsive
if vim.g.neovide then
vim.o.guifont = "Hack Nerd Font:h10"
end

View File

@ -1,28 +0,0 @@
return {
'goolord/alpha-nvim',
event = "VimEnter",
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
local alpha = require('alpha')
local dashboard = require('alpha.themes.dashboard')
dashboard.section.header.val = {
[[┌┐┌┌─┐┌─┐┬ ┬┬┌┬┐]],
[[│││├┤ │ │└┐┌┘││││]],
[[┘└┘└─┘└─┘ └┘ ┴┴ ┴]],
}
dashboard.section.buttons.val = {
dashboard.button("e", " New file", ":<cmd>ene<CR>"),
dashboard.button(",ff", "󰈞 Find file", "<cmd>Telescope find_files<CR>"),
dashboard.button(",fg", "󰈬 Find word", "<cmd>Telescope live_grep<CR>"),
dashboard.button(",zn", "󱞁 Write note", "<cmd>Telekasten new_note<CR>"),
dashboard.button(",zf", "󱙓 Find note", "<cmd>Telekasten find_notes<CR>"),
dashboard.button("q", "󰅚 Quit", ":qa<CR>"),
}
alpha.setup(dashboard.config)
end
}
-- 󰊄 Recently opened files SPC f h
--  Frecency/MRU SPC f r
--  Jump to bookmarks SPC f m
--  Open last session SPC s l

View File

@ -1,5 +0,0 @@
return {
'windwp/nvim-autopairs',
event = 'InsertEnter',
config = {},
}

View File

@ -1,8 +0,0 @@
return {
"akinsho/bufferline.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
vim.opt.termguicolors = true
require("bufferline").setup {}
end
}

View File

@ -1,53 +0,0 @@
return {
"hrsh7th/nvim-cmp", -- Autocompletion plugin
dependencies = {
"hrsh7th/cmp-nvim-lsp", -- LSP source for nvim-cmp
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip", -- Snippets source for nvim-cmp
"L3MON4D3/LuaSnip", -- Snippets plugin
},
config = function()
require('cmp').setup {
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = require('cmp').mapping.preset.insert({
['<C-u>'] = require('cmp').mapping.scroll_docs(-4), -- Up
['<C-d>'] = require('cmp').mapping.scroll_docs(4), -- Down
-- C-b (back) C-f (forward) for snippet placeholder navigation.
['<C-Space>'] = require('cmp').mapping.complete(),
['<CR>'] = require('cmp').mapping.confirm {
behavior = require('cmp').ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = require('cmp').mapping(function(fallback)
if require('cmp').visible() then
require('cmp').select_next_item()
elseif require('luasnip').expand_or_jumpable() then
require('luasnip').expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = require('cmp').mapping(function(fallback)
if require('cmp').visible() then
require('cmp').select_prev_item()
elseif require('luasnip').jumpable(-1) then
require('luasnip').jump(-1)
else
fallback()
end
end, { 'i', 's' }),
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
},
}
end,
}

View File

@ -1,22 +0,0 @@
return {
"numToStr/Comment.nvim",
config = {
toggler = {
line = '<leader>c<space>',
block = '<leader>b<space>'
},
opleader = {
line = '<leader>c',
block = '<leader>b',
},
extra = {
above = '<leader>cO',
below = '<leader>co',
eol = '<leader>cA',
},
mappings = {
basic = true,
extra = false,
},
},
}

View File

@ -1,31 +0,0 @@
return {
'dinhhuy258/git.nvim',
config = {
default_mappings = true, -- NOTE: `quit_blame` and `blame_commit` are still merged to the keymaps even if `default_mappings = false`
keymaps = {
-- Open blame window
blame = "<Leader>gb",
-- Close blame window
quit_blame = "q",
-- Open blame commit
blame_commit = "<CR>",
-- Open file/folder in git repository
browse = "<Leader>go",
-- Open pull request of the current branch
open_pull_request = "<Leader>gp",
-- Create a pull request with the target branch is set in the `target_branch` option
create_pull_request = "<Leader>gn",
-- Opens a new diff that compares against the current index
diff = "<Leader>gd",
-- Close git diff
diff_close = "<Leader>gD",
-- Revert to the specific commit
revert = "<Leader>gr",
-- Revert the current file to the specific commit
revert_file = "<Leader>gR",
},
-- Default target branch when create a pull request
target_branch = "main",
}
}

View File

@ -1,9 +0,0 @@
return {
"ellisonleao/gruvbox.nvim",
lazy = false,
priority = 1000,
config = function()
vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])
end
}

View File

@ -1,10 +0,0 @@
return {
"lukas-reineke/indent-blankline.nvim",
dependencies = { 'nvim-treesitter/nvim-treesitter' },
config = {
-- show_current_context = true,
-- show_current_context_start = true,
show_current_context = false,
show_current_context_start = false,
},
}

View File

@ -1,7 +0,0 @@
return {
"psliwka/vim-smoothie",
"tpope/vim-unimpaired",
"tpope/vim-surround",
"tpope/vim-fugitive",
"mzlogin/vim-markdown-toc",
}

View File

@ -1,110 +0,0 @@
return {
"neovim/nvim-lspconfig",
lazy = false,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
},
config = function()
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require("lspconfig")
lspconfig.pyright.setup { capabilities = capabilities }
lspconfig.ruff_lsp.setup { capabilities = capabilities }
lspconfig.nixd.setup { capabilities = capabilities }
lspconfig.jsonls.setup { capabilities = capabilities }
lspconfig.beancount.setup { capabilities = capabilities }
lspconfig.ltex.setup { capabilities = capabilities }
lspconfig.terraformls.setup { capabilities = capabilities }
lspconfig.tflint.setup { capabilities = capabilities }
lspconfig.docker_compose_language_service.setup {
root_dir = lspconfig.util.root_pattern("docker-compose.yaml", "docker-compose.yml"),
filetypes = { "yaml", "yaml.docker-compose" },
capabilities = capabilities,
}
lspconfig.dockerls.setup { capabilities = capabilities }
-- lspconfig.sqlls.setup {capabilities = capabilities}
lspconfig.lua_ls.setup {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
capabilities = capabilities
}
lspconfig.efm.setup {
init_options = { documentFormatting = true },
filetypes = { "python", "sh" },
settings = {
rootMarkers = { ".git/", "pyproject.toml" },
languages = {
python = { { formatCommand = "black -", formatStdin = true } },
sql = { {
formatCommand = "sqlfluff fix --dialect bigquery -",
formatStdin = true
} },
sh = { {
formatCommand = "shfmt -i 4 -bn -sr -p -ci",
formatStdin = true,
lintCommand = "shellcheck -f gcc -x",
lintSource = "shellcheck",
lintFormats = {
"%f:%l:%c: %trror: %m",
"%f:%l:%c: %tarning: %m",
"%f:%l:%c: %tote: %m",
}
} },
},
},
capabilities = capabilities
}
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
end
})
end,
keys = {
{ 'gD', vim.lsp.buf.declaration },
{ 'gd', vim.lsp.buf.definition },
{ 'K', vim.lsp.buf.hover },
{ 'gi', vim.lsp.buf.implementation },
{ '<C-k>', vim.lsp.buf.signature_help },
{ '<space>wa', vim.lsp.buf.add_workspace_folder },
{ '<space>wr', vim.lsp.buf.remove_workspace_folder },
{ '<space>D', vim.lsp.buf.type_definition },
{ '<space>rn', vim.lsp.buf.rename },
{ 'gr', vim.lsp.buf.references },
{ '<space>ca', vim.lsp.buf.code_action, { 'n', 'v' } },
{ '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end },
{ '<space>f', function()
vim.lsp.buf.format { async = true }
end },
},
}

View File

@ -1,10 +0,0 @@
return {
'nvim-lualine/lualine.nvim',
dependenceies = { 'nvim-tree/nvim-web-devicons' },
config = {
icons_enabled = true,
theme = 'gruvbox_dark',
component_separators = '|',
section_separators = '',
}
}

View File

@ -1,12 +0,0 @@
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
cmd = "Neotree",
keys = { { "<leader>t", "<cmd>Neotree toggle<cr>" } },
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
"s1n7ax/nvim-window-picker",
}
}

View File

@ -1,7 +0,0 @@
return {
"jpalardy/vim-slime",
config = function()
vim.g["slime_target"] = "tmux"
vim.g["slime_python_ipython"] = 1
end
}

View File

@ -1,58 +0,0 @@
return {
'renerocksai/telekasten.nvim',
cmd = "Telekasten",
dependencies = {
'nvim-telescope/telescope.nvim',
'renerocksai/calendar-vim',
{
'nvim-telescope/telescope-media-files.nvim',
dependencies = {
'nvim-lua/popup.nvim',
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
'nvim-telescope/telescope-media-files.nvim',
},
},
},
config = function()
require('telekasten').setup {
home = vim.fn.expand("~/notes"),
daily = vim.fn.expand("~/notes/daily"),
weeklies = vim.fn.expand("~/notes/weeklies"),
templates = vim.fn.expand("~/notes/templates"),
auto_set_filetype = false,
install_syntax = true,
media_previewer = "telescope-media-files",
}
vim.cmd("hi tklink ctermfg=72 guifg=#689d6a cterm=bold,underline gui=bold,underline")
vim.cmd("hi tkBrackets ctermfg=gray guifg=gray")
end,
keys = {
{ "<leader>z", '<cmd>Telekasten panel<cr>' },
{ "<leader>zf", '<cmd>Telekasten find_notes<cr>' },
{ "<leader>zd", '<cmd>Telekasten find_daily_notes<cr>' },
{ "<leader>zg", '<cmd>Telekasten search_notes<cr>' },
{ "<leader>zz", '<cmd>Telekasten follow_link<cr>' },
{ "<leader>zT", '<cmd>Telekasten goto_today<cr>' },
{ "<leader>zW", '<cmd>Telekasten goto_thisweek<cr>' },
{ "<leader>zw", '<cmd>Telekasten find_weekly_notes<cr>' },
{ "<leader>zn", '<cmd>Telekasten new_note<cr>' },
{ "<leader>zN", '<cmd>Telekasten new_templated_note<cr>' },
{ "<leader>zy", '<cmd>Telekasten yank_notelink<cr>' },
{ "<leader>zc", '<cmd>Telekasten show_calendar<cr>' },
{ "<leader>zi", '<cmd>Telekasten paste_img_and_link<cr>' },
{ "<leader>zt", '<cmd>Telekasten toggle_todo<cr>' },
{ "<leader>zb", '<cmd>Telekasten show_backlinks<cr>' },
{ "<leader>zF", '<cmd>Telekasten find_friends<cr>' },
{ "<leader>zp", '<cmd>Telekasten preview_img<cr>' },
{ "<leader>zm", '<cmd>Telekasten browse_media<cr>' },
{ "<leader>#", '<cmd>Telekasten show_tags<cr>' },
{ "<leader>zI", function() require('telekasten').insert_img_link({ i = true }) end },
{ "<leader>zt", function() require('telekasten').toggle_todo({ v = true }) end, "v" },
{ "<leader>zt", function() require('telekasten').toggle_todo({ i = true }) end, "i" },
{ "<leader>#", function() require('telekasten').show_tags({ i = true }) end, "i" },
-- { "[[", function() require('telekasten').insert_link({ i = true }) end, "i" },
{ "<leader>zC", "<cmd>CalendarT<cr>" },
},
}

View File

@ -1,59 +0,0 @@
return {
'nvim-telescope/telescope.nvim',
cmd = "Telescope",
dependencies = {
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make'
},
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-symbols.nvim',
"nvim-telescope/telescope-bibtex.nvim",
{
'nvim-telescope/telescope-media-files.nvim',
dependencies = {
'nvim-lua/popup.nvim',
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
'nvim-telescope/telescope-media-files.nvim',
},
},
},
config = function()
local telescope = require("telescope")
telescope.setup {
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
},
-- media_files = {
-- -- filetypes whitelist
-- -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
-- filetypes = { "png", "webp", "jpg", "jpeg" },
-- -- find command (defaults to `fd`)
-- find_cmd = "rg"
-- },
bibtex = {
global_files = { vim.fn.expand("~/notes/refs") },
}
}
}
telescope.load_extension("fzf")
telescope.load_extension("media_files")
telescope.load_extension("bibtex")
end,
keys = {
{ '<leader>ff', '<cmd>Telescope find_files<cr>' },
{ '<leader>fg', '<cmd>Telescope live_grep<cr>' },
{ '<leader>fb', '<cmd>Telescope buffers<cr>' },
{ '<leader>fh', '<cmd>Telescope help_tags<cr>' },
{ '<leader>fs', function()
require('telescope_builtin').symbols({ sources = 'emoji', 'gitmoji', 'nerd' })
end },
-- { '<leader>fb', "<cmd>Telescope bibtex<cr>"}
}
}

View File

@ -1,12 +0,0 @@
return {
"christoomey/vim-tmux-navigator",
config = function()
vim.g["tmux_navigator_no_mappings"] = 1
end,
keys = {
{ "<A-h>", "<cmd>TmuxNavigateLeft<cr>" },
{ "<A-j>", "<cmd>TmuxNavigateDown<cr>" },
{ "<A-k>", "<cmd>TmuxNavigateUp<cr>" },
{ "<A-l>", "<cmd>TmuxNavigateRight<cr>" },
}
}

View File

@ -1,7 +0,0 @@
return {
"nvim-treesitter/nvim-treesitter-context",
dependencies = { 'nvim-treesitter/nvim-treesitter' },
config = {
enable = true,
},
}

View File

@ -1,17 +0,0 @@
return {
"nvim-treesitter/nvim-treesitter",
dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" },
build = ":TSUpdate",
config = function()
require('nvim-treesitter.configs').setup {
ensure_installed = "all",
sync_install = true,
ignore_install = {},
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
}
end
}

View File

@ -1,13 +0,0 @@
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
cmd = { "TroubleToggle", "Trouble" },
keys = {
{ '<leader>xx', '<cmd>TroubleToggle<cr>' },
{ '<leader>xw', '<cmd>TroubleToggle workspace_diagnostics<cr>' },
{ '<leader>xd', '<cmd>TroubleToggle document_diagnostics<cr>' },
{ '<leader>xq', '<cmd>TroubleToggle quickfix<cr>' },
{ '<leader>xl', '<cmd>TroubleToggle loclist<cr>' },
{ 'gR', '<cmd>TroubleToggle lsp_references<cr>' },
}
}

View File

@ -1,11 +0,0 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 500
end,
config = function()
require("which-key").setup()
end
}