diff --git a/init.lua b/init.lua index d3dd2f2..62d53a6 100644 --- a/init.lua +++ b/init.lua @@ -12,5 +12,6 @@ end vim.opt.rtp:prepend(lazypath) require("vim_options") +require("keybinds") require("lazy").setup("plugins") diff --git a/lua/keybinds.lua b/lua/keybinds.lua new file mode 100644 index 0000000..dc2c240 --- /dev/null +++ b/lua/keybinds.lua @@ -0,0 +1,2 @@ +vim.keymap.set("n", "", ":bdelete") +vim.keymap.set("n", "", ":enew") diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index b2dbc39..fd80dcd 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -10,8 +10,8 @@ return { require("mason-lspconfig").setup({ ensure_installed = { "lua_ls", - "ruff_lsp", "pyright", + "clangd", } }) end @@ -26,9 +26,13 @@ return { capabilities=capabilities }) lspconfig.pyright.setup({ - capabilities=capabilities + capabilities=capabilities, + filetypes = {"python"} }) - lspconfig.ruff_lsp.setup({ + --lspconfig.ruff_lsp.setup({ + -- capabilities=capabilities + --}) + lspconfig.clangd.setup({ capabilities=capabilities }) diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua index affb347..db7d0d9 100644 --- a/lua/plugins/neotree.lua +++ b/lua/plugins/neotree.lua @@ -1,12 +1,60 @@ +local is_neotree_focused = function() + -- Get our current buffer number + local bufnr = vim.api.nvim_get_current_buf and vim.api.nvim_get_current_buf() or vim.fn.bufnr() + -- Get all the available sources in neo-tree + for _, source in ipairs(require("neo-tree").config.sources) do + -- Get each sources state + local state = require("neo-tree.sources.manager").get_state(source) + -- Check if the source has a state, if the state has a buffer and if the buffer is our current buffer + if state and state.bufnr and state.bufnr == bufnr then + return true + end + end + return false +end + +local function is_neotree_open() + local manager = require("neo-tree.sources.manager") + local renderer = require("neo-tree.ui.renderer") + + local success, state = pcall(manager.get_state, "filesystem") + + if not success then + return false + end + + local window_exists = renderer.window_exists(state) + return window_exists +end + +-- If the tree is currently open and focused, then close it. If it's not open, or it's open +-- but not currently focused, it is made focused. +-- Effectively prevents the need to close and re-open it to gain focus of the tree. +local function toggle() + local cmd = require("neo-tree.command") + if is_neotree_open() and is_neotree_focused() then + cmd.execute({ + action = "close", + }) + else + cmd.execute({ + action = "focus", + source = "filesystem", + position = "left", + }) + end +end + return { "nvim-neo-tree/neo-tree.nvim", branch = "v3.x", dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", }, - config=function() - vim.keymap.set("n", "", ":Neotree filesystem toggle left") - end + config = function() + --vim.keymap.set("n", "", ":Neotree filesystem toggle left") + vim.keymap.set("n", "", toggle, {}) + end, } diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index 9ce7259..118bf20 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -2,13 +2,29 @@ return { "nvimtools/none-ls.nvim", config=function() local null_ls = require("null-ls") + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) null_ls.setup({ sources = { - -- null_ls.builtins.formatting.stylua, -- THIS SUCKS ASS - null_ls.builtins.formatting.isort, + null_ls.builtins.formatting.stylua, -- THIS SUCKS ASS null_ls.builtins.formatting.black, - } - + null_ls.builtins.diagnostics.mypy, + --null_ls.builtins.diagnostics.ruff, + }, + on_attach = function(client, bufnr) + if 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({bufnr = bufnr}) + end + }) + end + end }) vim.keymap.set("n", "f", vim.lsp.buf.format, {}) end diff --git a/lua/plugins/tabline.lua b/lua/plugins/tabline.lua new file mode 100644 index 0000000..dd0c3f3 --- /dev/null +++ b/lua/plugins/tabline.lua @@ -0,0 +1,20 @@ +return { + "romgrk/barbar.nvim", + config = function () + require('lazy').setup { + {'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status + 'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons + }, + init = function() vim.g.barbar_auto_setup = false end, + opts = { + -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: + -- animation = true, + -- insert_at_start = true, + -- …etc. + }, + version = '^1.0.0', -- optional: only update when a new 1.x version is released + }, +} end +} diff --git a/lua/plugins/transparent.lua b/lua/plugins/transparent.lua new file mode 100644 index 0000000..eb4783a --- /dev/null +++ b/lua/plugins/transparent.lua @@ -0,0 +1,17 @@ +return { + "xiyaowong/transparent.nvim", + config = function () + require("transparent").setup({ -- Optional, you don't have to run setup. + groups = { -- table: default groups + 'Normal', 'NormalNC', 'Comment', 'Constant', 'Special', 'Identifier', + 'Statement', 'PreProc', 'Type', 'Underlined', 'Todo', 'String', 'Function', + 'Conditional', 'Repeat', 'Operator', 'Structure', 'LineNr', 'NonText', + 'SignColumn', 'CursorLine', 'CursorLineNr', 'StatusLine', 'StatusLineNC', + 'EndOfBuffer', + }, + extra_groups = {}, -- table: additional groups that should be cleared + exclude_groups = {}, -- table: groups you don't want to clear +}) + end +} + diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index b4f13bf..8db2747 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -4,7 +4,7 @@ return { config=function() local config = require("nvim-treesitter.configs") config.setup({ - ensure_installed = {"lua", "python", "rust"}, + ensure_installed = {"lua", "python", "rust", "c"}, highlight = {enable=true}, indent = {enable=true}, }) diff --git a/lua/vim_options.lua b/lua/vim_options.lua index 5269efa..e31209c 100644 --- a/lua/vim_options.lua +++ b/lua/vim_options.lua @@ -9,6 +9,7 @@ vim.opt.number = true vim.opt.relativenumber = true vim.opt.fillchars="eob: " -- Remove the trailing ~s vim.opt.showmode = false +vim.opt.cursorline = true -- Instant.nvim for Live Share function require("instant_options") diff --git a/test.py b/test.py new file mode 100644 index 0000000..ef7c3c8 --- /dev/null +++ b/test.py @@ -0,0 +1,18 @@ +def primes(n: int): + """Return whether the number is prime for the first n primes.""" + sieve = [True] * n + + res = [] + + for i in range(2, n): + if sieve[i]: + res.append(i) + for j in range(i * i, n, i): + sieve[j] = False + + return res + + +xs = primes(100) +ys = primes(200) +print(xs)