feat(nvim): make golang a devshell

This commit is contained in:
matt1432 2025-06-01 11:27:05 -04:00
parent 8cd000fb6b
commit 3a687ae95c
19 changed files with 64 additions and 11 deletions
configurations/android
devShells/neovim-shells
homeManagerModules/neovim

View file

@ -52,7 +52,6 @@
user = "nix-on-droid";
ideConfig = {
enableGolang = false;
enableJava = false;
enableNix = false;
};

View file

@ -25,6 +25,7 @@ in
"kotlin"
"lua"
"markdown"
"golang"
"python"
"qml"
"rust"

View file

@ -25,10 +25,6 @@ in {
type = types.bool;
default = true;
};
enableGolang = mkOption {
type = types.bool;
default = true;
};
enableJava = mkOption {
type = types.bool;
default = true;

View file

@ -15,6 +15,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'cpp', 'c' },
@ -39,6 +40,7 @@ in {
config =
# lua
''
--
local lsp = require('lspconfig');
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();

View file

@ -22,6 +22,7 @@ in {
config =
# lua
''
--
vim.api.nvim_create_autocmd('User', {
pattern = 'RoslynInitialized',

View file

@ -36,6 +36,7 @@ in {
mkBefore
# lua
''
--
-- Init object to keep track of loaded devShells
local devShells = {};
@ -93,6 +94,7 @@ in {
config =
# lua
''
--
require('nvim-autopairs').setup({});
'';
};
@ -103,6 +105,7 @@ in {
config =
# lua
''
--
-- Disable virtual_text since it's redundant due to tiny-inline-diagnostic.
vim.diagnostic.config({
virtual_text = false,

View file

@ -1,27 +1,42 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
cfg = config.programs.neovim;
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
in {
config = mkIf (cfg.enable && cfg.ideConfig.enableGolang) {
config = mkIf cfg.enable {
programs = {
neovim = {
extraPackages = with pkgs; [go gopls];
extraLuaConfig =
# lua
''
--
local lsp = require('lspconfig');
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
lsp.gopls.setup({
cmd = { '${pkgs.gopls}/bin/gopls' },
capabilities = default_capabilities,
autostart = false,
});
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'go', 'gomod', 'gowork', 'gotmpl' },
callback = function()
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
if (devShells['golang'] == nil) then
devShells['golang'] = 1;
require('nix-develop').nix_develop_extend({'${flakeEnv}#golang'}, function()
vim.cmd[[LspStart]];
end);
end
end,
});
'';
};

View file

@ -0,0 +1,12 @@
{
mkShell,
go,
gopls,
...
}:
mkShell {
packages = [
go
gopls
];
}

View file

@ -13,6 +13,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.filetype.add({
pattern = { [ '.*/hypr/.*%.conf' ] = 'hyprlang' },
});

View file

@ -22,6 +22,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = 'java',
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
@ -36,6 +37,7 @@ in {
config =
# lua
''
--
local startJdtls = function()
local config = {
capabilities = require('cmp_nvim_lsp').default_capabilities(),

View file

@ -14,6 +14,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'json', 'yaml', '.clang-.*' },

View file

@ -14,6 +14,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'kotlin' },

View file

@ -20,6 +20,7 @@ in {
config =
# lua
''
--
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {

View file

@ -27,6 +27,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'markdown', 'tex' },
@ -69,6 +70,7 @@ in {
config =
# lua
''
--
require('easytables').setup();
'';
}
@ -99,6 +101,7 @@ in {
in
# lua
''
--
vim.g.knap_settings = {
-- HTML
htmloutputext = 'html',

View file

@ -74,6 +74,7 @@ in {
extraLuaConfig =
# lua
''
--
require('lspconfig').nixd.setup({
capabilities = require('cmp_nvim_lsp').default_capabilities(),

View file

@ -14,6 +14,7 @@ in {
extraLuaConfig =
# lua
''
--
local lsp = require('lspconfig');
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();

View file

@ -14,6 +14,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'qml' },

View file

@ -14,6 +14,7 @@ in {
extraLuaConfig =
# lua
''
--
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'rust' },

View file

@ -20,6 +20,7 @@ in {
extraLuaConfig =
# lua
''
--
local lsp = require('lspconfig');
local tsserver = require('typescript-tools');
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
@ -35,7 +36,16 @@ in {
end;
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, {
pattern = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx', 'css', 'scss' },
pattern = {
'javascript',
'javascriptreact',
'javascript.jsx',
'typescript',
'typescriptreact',
'typescript.tsx',
'css',
'scss',
},
callback = function()
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
@ -185,6 +195,7 @@ in {
config =
# lua
''
--
local packageInfo = require('package-info');
packageInfo.setup({