Merge branch 'nvim_config'
This commit is contained in:
commit
af1f453962
5 changed files with 365 additions and 68 deletions
|
|
@ -68,7 +68,7 @@
|
|||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
# deploy-rs.packages.${system}.deploy-rs
|
||||
# deploy-rs.packages.${system}.deploy-rs
|
||||
pkgs.deploy-rs
|
||||
];
|
||||
shellHook = ''
|
||||
|
|
|
|||
|
|
@ -37,17 +37,17 @@
|
|||
# See https://wiki.hyprland.org/Configuring/Monitors/
|
||||
# monitor=name,resolution,position,scale
|
||||
monitor,preferred,auto,auto
|
||||
${
|
||||
${
|
||||
if nixosConfig.networking.hostName == "thor" then
|
||||
''
|
||||
monitor=HDMI-A-1,preferred,0x0,auto,transform,3
|
||||
monitor=DP-2,preferred,1080x420,auto
|
||||
''
|
||||
''
|
||||
else if nixosConfig.networking.hostName == "odin" then
|
||||
''
|
||||
monitor=eDP-1,preferred,320x1440,1
|
||||
monitor=DP-1,preferred,0x0,1
|
||||
''
|
||||
''
|
||||
else ""
|
||||
}
|
||||
|
||||
|
|
@ -165,10 +165,10 @@
|
|||
bind = SUPER, RETURN, exec, kitty
|
||||
bind = SUPER, W, killactive,
|
||||
bind = SUPER, M, exec, way-lockscreen
|
||||
bind = SUPER_ALT_L, Q, exit,
|
||||
bind = SUPER_ALT_L, Q, exit,
|
||||
bind = SUPER, E, exec, nautilus
|
||||
bind = SUPER_SHIFT, E, exec, nemo
|
||||
bind = SUPER, V, togglefloating,
|
||||
bind = SUPER, V, togglefloating,
|
||||
bind = SUPER_SHIFT, SPACE, exec, wofi --show run --allow-images -D key_expand=Tab -M=fuzzy -i
|
||||
bind = SUPER, SPACE, exec, wofi --show drun --allow-images -D key_expand=Tab -M=fuzzy -i
|
||||
bind = SUPER, F, fullscreen,
|
||||
|
|
|
|||
33
modules/hm/nvim/nvim-cmp-config.lua
Normal file
33
modules/hm/nvim/nvim-cmp-config.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
-- loads vscode style snippets from installed plugins (eg. friendly-snippets)
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
completion = {
|
||||
completeopt = "menu,menuone,preview,noselect"
|
||||
},
|
||||
snippet = { -- configura how nvim-cmp interacts with snippet engine
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
|
||||
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||
["<C-e>"] = cmp.mapping.abort(), -- close cmpletion window
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false })
|
||||
}),
|
||||
-- sources for autocompletion
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" }, -- nvim_lsp
|
||||
{ name = "luasnip" }, -- snippets
|
||||
{ name = "buffer" }, -- text within current buffer
|
||||
{ name = "path" }, -- file system paths
|
||||
}),
|
||||
})
|
||||
|
||||
92
modules/hm/nvim/nvim-lspconfig.lua
Normal file
92
modules/hm/nvim/nvim-lspconfig.lua
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
local lspconfig = require('lspconfig')
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
|
||||
-- Keymaps
|
||||
local keymap = vim.keymap
|
||||
local opts = { noremap = true, silent = true }
|
||||
local on_attach = function(client, bufnr)
|
||||
opts.buffer = bufnr
|
||||
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts)
|
||||
opts.desc = "Go to declaration"
|
||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
opts.desc = "Go to definition"
|
||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts)
|
||||
opts.desc = "See available code actions"
|
||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
opts.desc = "Smart rename"
|
||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
opts.desc = "Smart show buffer diagnostics"
|
||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts)
|
||||
opts.desc = "Smart show line diagnostics"
|
||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
|
||||
opts.desc = "Go to previous diagnostic"
|
||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||
opts.desc = "Go to next diagnostic"
|
||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||
opts.desc = "Show documentation for what is under cursor"
|
||||
keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
opts.desc = "Restart LSP"
|
||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts)
|
||||
end
|
||||
|
||||
-- Change the Diagnostic symbols in the sign column (gutter)
|
||||
-- (not in youtube nvim video)
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
|
||||
-- LSP configuration
|
||||
lspconfig["html"].setup { capabilities = capabilities, on_attach = on_attach}
|
||||
lspconfig["pylsp"].setup { capabilities = capabilities, on_attach = on_attach}
|
||||
lspconfig["nil_ls"].setup { capabilities = capabilities, on_attach = on_attach, settings = {
|
||||
["nil"] = {
|
||||
formatting = { command = { "nixpkgs-fmt" } },
|
||||
autoEvalInputs = true
|
||||
}
|
||||
}}
|
||||
lspconfig["rust_analyzer"].setup { capabilities = capabilities, on_attach = on_attach}
|
||||
lspconfig["texlab"].setup { capabilities = capabilities, on_attach = on_attach, settings = {
|
||||
texlab = {
|
||||
formatterLineLength = 0,
|
||||
bibtexFormatter = "latexindent",
|
||||
latexindent = { modifyLineBreaks = false },
|
||||
chktex = { onEdit = true },
|
||||
}
|
||||
}}
|
||||
lspconfig["clangd"].setup { capabilities = capabilities, on_attach = on_attach}
|
||||
lspconfig["marksman"].setup { capabilities = capabilities, on_attach = on_attach}
|
||||
lspconfig["yamlls"].setup { capabilities = capabilities, on_attach = on_attach, settings = {
|
||||
yaml = {
|
||||
keyOrdering = false,
|
||||
schemas = {
|
||||
["kubernetes"] = "*.yaml",
|
||||
["http://json.schemastore.org/github-workflow"] = ".github/workflows/*",
|
||||
["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}",
|
||||
["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}",
|
||||
["http://json.schemastore.org/prettierrc"] = ".prettierrc.{yml,yaml}",
|
||||
["http://json.schemastore.org/kustomization"] = "kustomization.{yml,yaml}",
|
||||
["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}",
|
||||
["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}",
|
||||
["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}",
|
||||
["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "*gitlab-ci*.{yml,yaml}",
|
||||
["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}",
|
||||
["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "*docker-compose*.{yml,yaml}",
|
||||
["https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json"] = "*flow*.{yml,yaml}",
|
||||
}
|
||||
}
|
||||
}}
|
||||
lspconfig["pylsp"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
-- lspconfig["cmake-language-server"].setup { capabilities = capabilities, on_attach = on_attach}
|
||||
-- lspconfig["vscode-css-language-server"].setup { capabilities = capabilities, on_attach = on_attach}
|
||||
|
|
@ -1,73 +1,245 @@
|
|||
{ pkgs, ... }: {
|
||||
{ pkgs, ... }:
|
||||
let vp = pkgs.vimPlugins; in {
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
plugins = [
|
||||
{
|
||||
plugin = pkgs.vimPlugins.airline;
|
||||
# config = "let g:airline#extensions#tabline#left_alt_sep = '>'";
|
||||
}
|
||||
pkgs.vimPlugins.vim-airline-themes
|
||||
{
|
||||
plugin = pkgs.vimPlugins.nightfox-nvim;
|
||||
config = "colorscheme nightfox";
|
||||
}
|
||||
{
|
||||
plugin = pkgs.vimPlugins.nvim-lspconfig;
|
||||
type = "lua";
|
||||
config = ''
|
||||
local lspconfig = require('lspconfig')
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
lspconfig.pylsp.setup {capabilities=capabilities}
|
||||
lspconfig.nil_ls.setup {capabilities=capabilities}
|
||||
lspconfig.rust_analyzer.setup {capabilities=capabilities}
|
||||
lspconfig.texlab.setup {capabilities=capabilities}
|
||||
'';
|
||||
}
|
||||
pkgs.vimPlugins.nvim-treesitter.withAllGrammars
|
||||
pkgs.vimPlugins.plenary-nvim
|
||||
pkgs.vimPlugins.mini-nvim
|
||||
pkgs.vimPlugins.telescope-nvim
|
||||
pkgs.vimPlugins.gitsigns-nvim
|
||||
pkgs.vimPlugins.nvim-tree-lua
|
||||
|
||||
# completion
|
||||
pkgs.vimPlugins.nvim-cmp
|
||||
|
||||
{
|
||||
plugin = pkgs.vimPlugins.cmp-nvim-lsp;
|
||||
type = "lua";
|
||||
config = ''
|
||||
local cmp = require("cmp")
|
||||
cmp.setup({
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-o>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "buffer" }
|
||||
})
|
||||
})
|
||||
'';
|
||||
}
|
||||
|
||||
# pkgs.vimPlugins.fugitive
|
||||
# pkgs.vimPlugins.surround
|
||||
# {
|
||||
# plugin = pkgs.vimPlugins.vim-airline-themes;
|
||||
# config = "let g:airline_theme='nightfox'";
|
||||
# }
|
||||
];
|
||||
# settings = { ignorecase = true; };
|
||||
coc.enable = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
|
||||
plugins = [
|
||||
# # Git related plugins
|
||||
# vp.fugitive
|
||||
# vp.rhubarb
|
||||
|
||||
# vp.lsp-zero-nvim
|
||||
# vp.nvim-cmp
|
||||
# vp.cmp-nvim-lsp
|
||||
# vp.nvim-lspconfig
|
||||
|
||||
vp.telescope-fzf-native-nvim
|
||||
{
|
||||
plugin = vp.telescope-nvim;
|
||||
type = "lua";
|
||||
config = ''
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-k>"] = actions.move_selection_previous, -- move to prev result
|
||||
["<C-j>"] = actions.move_selection_next, -- move to next result
|
||||
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
telescope.load_extension("fzf");
|
||||
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Fuzzy find files in cwd" })
|
||||
keymap.set("n", "<leader>fr", "<cmd>Telescope oldfiles<cr>", { desc = "Fuzzy find recent files" })
|
||||
keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>", { desc = "Find string in cwd" })
|
||||
keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>", { desc = "Fuzzy string under cursor in cwd" })
|
||||
'';
|
||||
}
|
||||
|
||||
vp.dressing-nvim # Better UI for input and selection
|
||||
|
||||
# Tree view
|
||||
# vp.chadtree
|
||||
vp.nerdtree-git-plugin
|
||||
vp.vim-devicons
|
||||
vp.nerdtree
|
||||
|
||||
vp.cmp-buffer # source for text in buffer
|
||||
vp.cmp-path # source for file system path
|
||||
vp.luasnip
|
||||
vp.cmp_luasnip
|
||||
vp.friendly-snippets
|
||||
{
|
||||
plugin = vp.nvim-cmp;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./nvim/nvim-cmp-config.lua;
|
||||
}
|
||||
|
||||
# # Detect tabstop and shiftwidth automatically
|
||||
# vp.sleuth
|
||||
|
||||
# {
|
||||
# plugin = vp.nvim-cmp;
|
||||
# type = "lua";
|
||||
# config = ''
|
||||
# require()
|
||||
# '';
|
||||
# }
|
||||
|
||||
# # LSP
|
||||
vp.fidget-nvim # fidget moving while LSP is working
|
||||
# vp.neodev-nvim
|
||||
# # vp.nvim-lspconfig
|
||||
vp.cmp-nvim-lsp
|
||||
{
|
||||
plugin = vp.nvim-lspconfig;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./nvim/nvim-lspconfig.lua;
|
||||
}
|
||||
|
||||
# # Autocompletion
|
||||
# ## Snippet engine & its associated nvim-cmp source
|
||||
# vp.luasnip
|
||||
# vp.cmp_luasnip
|
||||
# ## Adds LSP completion capabilities
|
||||
# vp.cmp-nvim-lsp
|
||||
# vp.cmp-path
|
||||
# ## Adds a number of user-friendly snippets
|
||||
# vp.friendly-snippets
|
||||
# ## NVIM CMP
|
||||
# vp.nvim-cmp
|
||||
|
||||
# # Useful plugin to show you pending keybinds
|
||||
# { plugin = vp.which-key-nvim; config = ''require("which-key").setup({})''; type = "lua"; }
|
||||
|
||||
# Adds git related signs to the gutter, as well as utilities for managing changes
|
||||
# {
|
||||
# plugin = vp.gitsigns-nvim;
|
||||
# config = ''
|
||||
# require("gitsigns").setup({
|
||||
# -- See `:help gitsigns.txt`
|
||||
# signs = {
|
||||
# add = { text = '+' },
|
||||
# change = { text = '~' },
|
||||
# delete = { text = '_' },
|
||||
# topdelete = { text = '‾' },
|
||||
# changedelete = { text = '~' },
|
||||
# },
|
||||
# on_attach = function(bufnr)
|
||||
# local gs = package.loaded.gitsigns
|
||||
|
||||
# local function map(mode, l, r, opts)
|
||||
# opts = opts or {}
|
||||
# opts.buffer = bufnr
|
||||
# vim.keymap.set(mode, l, r, opts)
|
||||
# end
|
||||
|
||||
# -- Navigation
|
||||
# map({ 'n', 'v' }, ']c', function()
|
||||
# if vim.wo.diff then
|
||||
# return ']c'
|
||||
# end
|
||||
# vim.schedule(function()
|
||||
# gs.next_hunk()
|
||||
# end)
|
||||
# return '<Ignore>'
|
||||
# end, { expr = true, desc = 'Jump to next hunk' })
|
||||
|
||||
# map({ 'n', 'v' }, '[c', function()
|
||||
# if vim.wo.diff then
|
||||
# return '[c'
|
||||
# end
|
||||
# vim.schedule(function()
|
||||
# gs.prev_hunk()
|
||||
# end)
|
||||
# return '<Ignore>'
|
||||
# end, { expr = true, desc = 'Jump to previous hunk' })
|
||||
|
||||
# -- Actions
|
||||
# -- visual mode
|
||||
# map('v', '<leader>hs', function()
|
||||
# gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
|
||||
# end, { desc = 'stage git hunk' })
|
||||
# map('v', '<leader>hr', function()
|
||||
# gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
|
||||
# end, { desc = 'reset git hunk' })
|
||||
# -- normal mode
|
||||
# map('n', '<leader>hs', gs.stage_hunk, { desc = 'git stage hunk' })
|
||||
# map('n', '<leader>hr', gs.reset_hunk, { desc = 'git reset hunk' })
|
||||
# map('n', '<leader>hS', gs.stage_buffer, { desc = 'git Stage buffer' })
|
||||
# map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' })
|
||||
# map('n', '<leader>hR', gs.reset_buffer, { desc = 'git Reset buffer' })
|
||||
# map('n', '<leader>hp', gs.preview_hunk, { desc = 'preview git hunk' })
|
||||
# map('n', '<leader>hb', function()
|
||||
# gs.blame_line { full = false }
|
||||
# end, { desc = 'git blame line' })
|
||||
# map('n', '<leader>hd', gs.diffthis, { desc = 'git diff against index' })
|
||||
# map('n', '<leader>hD', function()
|
||||
# gs.diffthis '~'
|
||||
# end, { desc = 'git diff against last commit' })
|
||||
|
||||
# -- Toggles
|
||||
# map('n', '<leader>tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' })
|
||||
# map('n', '<leader>td', gs.toggle_deleted, { desc = 'toggle git show deleted' })
|
||||
|
||||
# -- Text object
|
||||
# map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'select git hunk' })
|
||||
# end,
|
||||
# })
|
||||
# '';
|
||||
# type = "lua";
|
||||
# }
|
||||
|
||||
# Cool color scheme
|
||||
{
|
||||
plugin = vp.nightfox-nvim;
|
||||
config = "colorscheme nightfox";
|
||||
}
|
||||
|
||||
# Set lualine as statusline
|
||||
{
|
||||
plugin = vp.lualine-nvim;
|
||||
config = ''
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
theme = "nightfox",
|
||||
component_separators = "|",
|
||||
section_separators = "",
|
||||
},
|
||||
})
|
||||
'';
|
||||
type = "lua";
|
||||
}
|
||||
|
||||
# # Add indentation guides even on blank lines
|
||||
# {
|
||||
# # See `:help ibl`
|
||||
# plugin = vp.indent-blankline-nvim;
|
||||
# config = ''
|
||||
# require("ibl").setup({})
|
||||
# '';
|
||||
# type = "lua";
|
||||
# }
|
||||
|
||||
# # "gc" to comment visual regions/lines
|
||||
# {
|
||||
# plugin = vp.comment-nvim;
|
||||
# config = ''
|
||||
# require("Comment").setup({})
|
||||
# '';
|
||||
# type = "lua";
|
||||
# }
|
||||
|
||||
# vp.plenary-nvim
|
||||
# vp.telescope-fzf-native-nvim
|
||||
# vp.telescope-nvim
|
||||
|
||||
# vp.nvim-treesitter-textobjects
|
||||
# vp.nvim-treesitter
|
||||
];
|
||||
# settings = { ignorecase = true; };
|
||||
# coc.enable = true;
|
||||
extraConfig = ''
|
||||
set mouse=a
|
||||
set encoding=UTF-8
|
||||
set guifont=FiraCode\ Nerd\ Font\ Mono\ 10
|
||||
let g:airline_powerline_fonts = 1
|
||||
'';
|
||||
extraLuaConfig = ''
|
||||
vim.g.mapleader = " "
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue