Squashed commit of the following:

commit eb451fe1a7324b35621921cd232480d0fbbec34b
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 15:40:15 2023 +0300

    nvim bash

commit fe31d8e972e5729715f2f9a70e8226f35759dc9a
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 15:35:16 2023 +0300

    nvim nix

commit af96dff98e80c54eabff9d219119950993878e27
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 15:25:03 2023 +0300

    some js cleanup

commit ffee7d74c9c7c06f879afa8542c4f55492566bb7
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 15:20:41 2023 +0300

    nvim lua

commit 9607813c11893b96070cb056d03eda6b821f9282
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 15:11:20 2023 +0300

    server capabilities check for doc highlight

commit d889f14fb93c35f4d5a4d9e9430a5770d080ef96
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 14:29:47 2023 +0300

    adding servers

commit e91f8f81b6c2ccc35926cac13e71da1a8997b98a
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 13:42:26 2023 +0300

    lists

commit 9239ed57fe73dcde7c11547d211ebec1e8d3078f
Author: Ivan Dimitrov <ivan@idimitrov.dev>
Date:   Thu Oct 5 13:39:10 2023 +0300

    neovim split
This commit is contained in:
Ivan Dimitrov 2023-10-05 15:48:01 +03:00
parent 84937681db
commit f5e1e3cb5b
8 changed files with 182 additions and 83 deletions

View File

@ -0,0 +1,22 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
bash
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
nodePackages_latest.bash-language-server
shfmt
shellcheck
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
bashls = {}
})
'';
};
}

View File

@ -1,65 +1,48 @@
{ pkgs, lib, ... }: { { pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
diff
regex
vimdoc
comment
markdown
ungrammar
gitignore
gitcommit
git_rebase
git_config
gitattributes
dockerfile
];
in
{
imports = [ ./bash.nix ./nix.nix ./lua.nix ./js.nix ./util.nix ];
programs.neovim = { programs.neovim = {
enable = true; enable = true;
viAlias = true; viAlias = true;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
# nix
rnix-lsp
alejandra
# go
go
gopls
# c/c++
libclang
# lua
lua
lua-language-server
stylua
# js/ts
nodePackages_latest.prettier
nodePackages_latest.typescript
nodePackages_latest.typescript-language-server
nodePackages_latest."@tailwindcss/language-server"
nodePackages_latest."@prisma/language-server"
# bash
nodePackages_latest.bash-language-server
shfmt
shellcheck
# python
python311Packages.python-lsp-black
python311Packages.python-lsp-server
black
# haskell
ghc
haskell-language-server
# neovim
ripgrep ripgrep
# html
nodePackages_latest.vscode-html-languageserver-bin
]; ];
plugins = with pkgs.vimPlugins; [ plugins = with pkgs.vimPlugins; grammars ++ [
nvim-treesitter
nvim-surround nvim-surround
nvim-ts-autotag nvim-ts-autotag
vim-prisma
autoclose-nvim autoclose-nvim
barbar-nvim barbar-nvim
cmp-nvim-lsp cmp-nvim-lsp
comment-nvim comment-nvim
gitsigns-nvim gitsigns-nvim
luasnip luasnip
#nightfox-nvim
catppuccin-nvim catppuccin-nvim
nvim-cmp nvim-cmp
nvim-lspconfig nvim-lspconfig
nvim-treesitter.withAllGrammars
nvim-web-devicons nvim-web-devicons
plenary-nvim plenary-nvim
telescope-nvim telescope-nvim
telescope-nvim
toggleterm-nvim toggleterm-nvim
vim-vinegar vim-vinegar
lualine-nvim lualine-nvim
]; ];
extraLuaConfig = lib.fileContents ./nvim/init.lua; extraLuaConfig = lib.fileContents ./nvim/default.lua;
}; };
} }

View File

@ -0,0 +1,43 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
tsx
jsdoc
json
json5
jsonnet
http
html
astro
svelte
prisma
graphql
typescript
javascript
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
nodePackages_latest.prettier
nodePackages_latest.typescript
nodePackages_latest.typescript-language-server
nodePackages_latest."@tailwindcss/language-server"
nodePackages_latest."@prisma/language-server"
nodePackages_latest.vscode-html-languageserver-bin
];
plugins = with pkgs.vimPlugins; grammars ++ [
vim-prisma
];
extraLuaConfig = ''
addServers({
tsserver = {},
tailwindcss = {},
prismals = {},
html = {
cmd = { "html-languageserver", "--stdio" }
},
})
'';
};
}

View File

@ -0,0 +1,25 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
lua
luadoc
luau
luap
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
lua
lua-language-server
stylua
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
lua_ls = {}
})
'';
};
}

View File

@ -0,0 +1,21 @@
{ pkgs, lib, ... }:
let grammars = with pkgs.vimPlugins.nvim-treesitter-parsers; [
nix
];
in
{
programs.neovim = {
extraPackages = with pkgs; [
rnix-lsp
alejandra
];
plugins = with pkgs.vimPlugins; grammars ++ [
];
extraLuaConfig = ''
addServers({
rnix = {}
})
'';
};
}

View File

@ -1,14 +1,13 @@
-- START GLOBAL CONFIG vim.wo.number = true
vim.wo.number = true -- show numbers vim.o.scrolloff = 15
vim.o.scrolloff = 15 -- scrll if n lines left vim.o.hlsearch = false
vim.o.hlsearch = false -- highlight search
vim.o.updatetime = 20 vim.o.updatetime = 20
vim.o.autoread = true vim.o.autoread = true
vim.o.tabstop = 4 vim.o.tabstop = 4
vim.o.shiftwidth = 4 vim.o.shiftwidth = 4
vim.o.expandtab = true vim.o.expandtab = true
vim.g.mapleader = " " -- leader space vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true }) -- nop leader vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true }) -- nop leader
@ -36,36 +35,10 @@ nmap("<leader>r", "<cmd>!%:p<cr>")
nmap("<leader>ff", require("telescope.builtin").find_files) nmap("<leader>ff", require("telescope.builtin").find_files)
nmap("<leader>fw", require("telescope.builtin").live_grep) nmap("<leader>fw", require("telescope.builtin").live_grep)
nmap("<leader>e", vim.diagnostic.open_float) nmap("<leader>e", vim.diagnostic.open_float)
-- END GLOBAL CONFIG
-- START LSP
local highlight_filetypes = { "*.ts", "*.tsx", "*.js", "*.jsx", "*.html", "*.lua", "*.hs" }
local cmp = require("cmp") local cmp = require("cmp")
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
local servers = {
tsserver = {
settings = {
completions = {
completeFunctionCalls = true,
},
},
},
pylsp = {},
lua_ls = {},
rnix = {},
gopls = {},
tailwindcss = {},
prismals = {},
hls = {},
bashls = {},
html = {
cmd = { "html-languageserver", "--stdio" }
},
}
local cmp_capabilities = require("cmp_nvim_lsp").default_capabilities() local cmp_capabilities = require("cmp_nvim_lsp").default_capabilities()
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
nmap("<leader>ca", vim.lsp.buf.code_action) nmap("<leader>ca", vim.lsp.buf.code_action)
@ -76,18 +49,18 @@ local on_attach = function(client, bufnr)
end) end)
nmap("K", vim.lsp.buf.hover) nmap("K", vim.lsp.buf.hover)
nmap("gr", require("telescope.builtin").lsp_references) nmap("gr", require("telescope.builtin").lsp_references)
vim.api.nvim_create_autocmd("CursorHold", { if client.server_capabilities.documentHighlightProvider then
callback = function() vim.api.nvim_create_autocmd("CursorHold", {
vim.lsp.buf.document_highlight() callback = function()
end, vim.lsp.buf.document_highlight()
pattern = highlight_filetypes end,
}) })
vim.api.nvim_create_autocmd("CursorMoved", { vim.api.nvim_create_autocmd("CursorMoved", {
callback = function() callback = function()
vim.lsp.buf.clear_references() vim.lsp.buf.clear_references()
end, end,
pattern = highlight_filetypes })
}) end
end end
cmp.setup({ cmp.setup({
snippet = { snippet = {
@ -111,7 +84,6 @@ for server, cfg in pairs(servers) do
}) })
end end
-- END LSP
require 'nvim-treesitter.configs'.setup { require 'nvim-treesitter.configs'.setup {
autotag = { autotag = {

View File

@ -0,0 +1,27 @@
local servers = {}
local addServers = function(srv)
servers = vim.tbl_deep_extend("force", servers, srv)
end
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k, v in pairs(o) do
if type(k) ~= 'number' then k = '"' .. k .. '"' end
s = s .. '[' .. k .. '] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local function log(o)
local file = io.open("./.nvim.log", "a+")
if file then
file:write(os.date("%Y/%m/%d %H:%M:%S") .. " || " .. dump(o) .. "\n")
file:write("---\n")
file:close()
end
end

View File

@ -0,0 +1,6 @@
{ pkgs, lib, ... }:
{
programs.neovim = {
extraLuaConfig = lib.fileContents ./nvim/util.lua;
};
}