Move some stuff to modules
This commit is contained in:
parent
61640c0580
commit
08b0fbcd0c
30 changed files with 427 additions and 406 deletions
13
home-manager/neovim/bufferline.lua
Normal file
13
home-manager/neovim/bufferline.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
require("bufferline").setup({
|
||||
options = {
|
||||
diagnostics = "nvim_lsp",
|
||||
diagnostics_indicator = function(count, level, diagnostics_dict, context)
|
||||
local icon = level:match("error") and " " or " "
|
||||
return " " .. icon .. count
|
||||
end,
|
||||
separator_style = "slant",
|
||||
hover = { enabled = true, reveal = { "close" } },
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>ft", ":BufferLinePick<CR>", {})
|
43
home-manager/neovim/cmp.lua
Normal file
43
home-manager/neovim/cmp.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
luasnip.config.setup({})
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete({}),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = { { name = "nvim_lsp" }, { name = "luasnip" } },
|
||||
})
|
2
home-manager/neovim/commentary.lua
Normal file
2
home-manager/neovim/commentary.lua
Normal file
|
@ -0,0 +1,2 @@
|
|||
vim.cmd([[autocmd FileType nix setlocal commentstring=#%s]])
|
||||
vim.cmd([[autocmd FileType terraform setlocal commentstring=#%s]])
|
9
home-manager/neovim/core.lua
Normal file
9
home-manager/neovim/core.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
vim.o.background = "dark"
|
||||
vim.cmd([[colorscheme gruvbox]])
|
||||
vim.g.mapleader = ";"
|
||||
vim.o.signcolumn = "yes"
|
||||
vim.wo.number = true
|
||||
vim.wo.relativenumber = true
|
||||
vim.wo.cursorline = true
|
||||
vim.opt.termguicolors = true
|
||||
vim.o.mousemoveevent = true
|
82
home-manager/neovim/default.nix
Normal file
82
home-manager/neovim/default.nix
Normal file
|
@ -0,0 +1,82 @@
|
|||
{ pkgs, ... }: {
|
||||
config = {
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
defaultEditor = true;
|
||||
extraLuaConfig = builtins.readFile ./core.lua;
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
nil
|
||||
nodePackages.pyright
|
||||
gopls
|
||||
terraform-ls
|
||||
nixfmt-classic
|
||||
stylua
|
||||
black
|
||||
nixpkgs-fmt
|
||||
];
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-lspconfig;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./lspconfig.lua;
|
||||
}
|
||||
gruvbox-nvim
|
||||
{
|
||||
plugin = leap-nvim;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./leap.lua;
|
||||
}
|
||||
{
|
||||
plugin = telescope-nvim;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./telescope.lua;
|
||||
}
|
||||
{
|
||||
plugin = vim-commentary;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./commentary.lua;
|
||||
}
|
||||
vim-sleuth
|
||||
{
|
||||
plugin = gitsigns-nvim;
|
||||
type = "lua";
|
||||
config = ''require("gitsigns").setup()'';
|
||||
}
|
||||
{
|
||||
plugin = nvim-cmp;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./cmp.lua;
|
||||
}
|
||||
cmp-nvim-lsp
|
||||
friendly-snippets
|
||||
neodev-nvim
|
||||
luasnip
|
||||
cmp_luasnip
|
||||
{
|
||||
plugin = nvim-treesitter.withAllGrammars;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./treesitter.lua;
|
||||
}
|
||||
{
|
||||
plugin = bufferline-nvim;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./bufferline.lua;
|
||||
}
|
||||
nvim-web-devicons
|
||||
lsp-format-nvim
|
||||
{
|
||||
plugin = pkgs.vimPlugins.none-ls-nvim;
|
||||
type = "lua";
|
||||
config = builtins.readFile ./none-ls.lua;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
programs.git.extraConfig.core.editor = "nvim";
|
||||
};
|
||||
}
|
4
home-manager/neovim/leap.lua
Normal file
4
home-manager/neovim/leap.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
require("leap").add_default_mappings()
|
||||
-- Don't remap 'x' in visual mode.
|
||||
vim.keymap.del({ "x", "o" }, "x")
|
||||
vim.keymap.del({ "x", "o" }, "X")
|
58
home-manager/neovim/lspconfig.lua
Normal file
58
home-manager/neovim/lspconfig.lua
Normal file
|
@ -0,0 +1,58 @@
|
|||
require("lsp-format").setup({})
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
local bufmap = function(keys, func)
|
||||
vim.keymap.set("n", keys, func, { buffer = bufnr })
|
||||
end
|
||||
|
||||
bufmap("<leader>r", vim.lsp.buf.rename)
|
||||
bufmap("<leader>a", vim.lsp.buf.code_action)
|
||||
|
||||
bufmap("gd", vim.lsp.buf.definition)
|
||||
bufmap("gD", vim.lsp.buf.declaration)
|
||||
bufmap("gI", vim.lsp.buf.implementation)
|
||||
bufmap("<leader>D", vim.lsp.buf.type_definition)
|
||||
|
||||
bufmap("gr", require("telescope.builtin").lsp_references)
|
||||
bufmap("<leader>s", require("telescope.builtin").lsp_document_symbols)
|
||||
bufmap("<leader>S", require("telescope.builtin").lsp_dynamic_workspace_symbols)
|
||||
|
||||
bufmap("K", vim.lsp.buf.hover)
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, {})
|
||||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||
|
||||
require("neodev").setup()
|
||||
require("lspconfig").nil_ls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
require("lspconfig").pyright.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
require("lspconfig").gopls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
require("lspconfig").terraformls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
-- require'lspconfig'.efm.setup {
|
||||
-- on_attach = require("lsp-format").on_attach,
|
||||
-- init_options = {documentFormatting = true},
|
||||
-- settings = {
|
||||
-- languages = {
|
||||
-- lua = {{formatCommand = "lua-format -i", formatStdin = true}},
|
||||
-- nix = {{formatCommand = "nixfmt", formatStdin = true}}
|
||||
-- }
|
||||
-- },
|
||||
-- filetypes = {"lua", "nix"}
|
||||
-- }
|
53
home-manager/neovim/none-ls.lua
Normal file
53
home-manager/neovim/none-ls.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
-- renamed to none-ls
|
||||
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
|
||||
if not null_ls_status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
local formatting = null_ls.builtins.formatting
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
local code_actions = null_ls.builtins.code_actions
|
||||
|
||||
-- to setup format on save
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
formatting.stylua,
|
||||
formatting.black,
|
||||
formatting.nixpkgs_fmt,
|
||||
formatting.mix,
|
||||
},
|
||||
|
||||
-- configure format on save
|
||||
-- on_attach = function(current_client, bufnr)
|
||||
-- if current_client.supports_method("textDocument/formatting") then
|
||||
-- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
-- group = augroup,
|
||||
-- buffer = bufnr,
|
||||
-- callback = function()
|
||||
-- vim.lsp.buf.format({
|
||||
-- filter = function(client)
|
||||
-- -- only use null-ls for formatting instead of lsp server
|
||||
-- return client.name == "null-ls"
|
||||
-- end,
|
||||
-- bufnr = bufnr,
|
||||
-- })
|
||||
-- end,
|
||||
-- })
|
||||
-- end
|
||||
-- end,
|
||||
})
|
||||
|
||||
-- formatting command
|
||||
vim.api.nvim_create_user_command("Format", function()
|
||||
vim.lsp.buf.format(nil, 10000)
|
||||
end, {})
|
||||
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>fm",
|
||||
":Format<CR>",
|
||||
{ desc = "Format current buffer (also done on save)", noremap = true, silent = true }
|
||||
)
|
17
home-manager/neovim/telescope.lua
Normal file
17
home-manager/neovim/telescope.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
local builtin = require("telescope.builtin")
|
||||
|
||||
vim.keymap.set("n", "<leader>ff", builtin.find_files, {})
|
||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
|
||||
vim.keymap.set("n", "<leader>fb", builtin.buffers, {})
|
||||
vim.keymap.set("n", "<leader>fr", builtin.lsp_references, {})
|
||||
vim.keymap.set("n", "<leader>fs", builtin.lsp_document_symbols, {})
|
||||
|
||||
require("telescope").setup({
|
||||
pickers = {
|
||||
find_files = { theme = "dropdown" },
|
||||
live_grep = { theme = "dropdown" },
|
||||
buffers = { theme = "dropdown" },
|
||||
lsp_references = { theme = "dropdown" },
|
||||
lsp_document_symbols = { theme = "dropdown" },
|
||||
},
|
||||
})
|
9
home-manager/neovim/treesitter.lua
Normal file
9
home-manager/neovim/treesitter.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {},
|
||||
|
||||
auto_install = false,
|
||||
|
||||
highlight = { enable = true },
|
||||
|
||||
indent = { enable = true },
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue