1
2

競プロでNeovim×pythonを使う方法

Last updated at Posted at 2024-09-19

競プロでNeovim×pythonを使う方法

文章力が明らかに欠陥している中学生が書いた記事です。
どうぞ温かい目でご覧ください。

前提条件

Python
Neovim
Git
がインストールされている状態

完成図

output.gif

Lazy.vimのインストール

lazy.vimはプラグインマネージャーときれいなuiを提供します

# バックアップを取ります
mv ~/.config/nvim{,.bak}
mv ~/.local/share/nvim{,.bak}
mv ~/.local/state/nvim{,.bak}
mv ~/.cache/nvim{,.bak}

#インストール
git clone https://github.com/LazyVim/starter ~/.config/nvim

rm -rf ~/.config/nvim/.git

pythonのlspのセットアップ

Neovimの設定ディレクトリに移動し/lua/config/lazy.luaを開きます

/lua/config/lazy.lua
require("lazy").setup({
  spec= {
        { "LazyVim/LazyVim", import = "lazyvim.plugins" },
+ { import = "lazyvim.plugins.extras.lang.python" },
  }
})

これでpythonのlspの設定が完了します

便利プラグイン

toggleterm.nvim

簡単にターミナルを開くためのプラグインです

Neovimの設定ディレクトリに/lua/plugins/utils.lua
を作成します
ファイル名は何でもいいです

/lua/plugins/utils.lua
return {

  -- amongst your other plugins
  { "akinsho/toggleterm.nvim", version = "*", config = true },
  {
    "akinsho/toggleterm.nvim",
    version = "*",
    opts = {--[[ things you want to change go here]]
    },
  },
}

そしてinit.luaに設定を加えます

init.lua
require("config.lazy")

+ require("toggleterm").setup({
+ size = 20,
+ open_mapping=[[<c-\>]],
+ hide_numbers = true, 
+ shade_filetypes = {},
+ shade_terminals = true,
+ shading_factor = "1",
+ start_in_insert = true, 
+ persist_size = true,
+ direction = "horizontal",
+ close_on_exit = true, 
+ shell = vim.o.shell, 
})

nvim-scrollbar

行番号の左にスクロールバーを作成します

/lua/plugins/utils.lua
+ { "petertriho/nvim-scrollbar" },

init.luaに

init.lua
+ require("ibl").setup()

これで完成です

最後に

結構簡単にできますのでぜひ試してみてください
コメントがあればご気軽にどうぞ

追記

2024/9/23
toggletermのセットアップにコロンとカッコが抜けていたところを修正しました。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2